博文
SJLR(2006-12-15 11:38:00)
摘要:import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.*;
import java.util.*;
//Runtime.getRuntime().freeMemory()察看内存
/**
方法内的变量只能在方法内使用
*/
public class SJLR extends MIDlet{
private DrawMenu drawmenu;//菜单类
private SJLRMenu sjlrmenu;
public void startApp(){
//drawmenu=new DrawMenu(Display.getDisplay(this));
sjlrmenu=new SJLRMenu(Display.getDisplay(this));
}
public void pauseApp(){}
public void destroyApp(boolean e){
notifyDestroyed();
}
/**
赏金猎人主菜单
*/
class SJLRMenu extends GameCanvas implements Runnable{
private Display display;
private Sprite sjlrSprite;//主菜单图片
private Sprite itemSprite[]=new Sprite[6];
private int nowPosition=1;
pr......
J2ME 菜单制作方法一(2006-12-11 08:56:00)
摘要://///////////////////////////////////////////////////////////////////////////////////////////////////////
/**
*菜单制作,涵数
*/
//要传进来的Graphics,菜单宽,菜单间隔,菜单项目数
/**
*内部值,可以释放,方便修改
*/
private void drawMenu(Graphics graphics,int MenuX,int MenuY,int number){
private Graphics g;
private int x,y;
private int num;
g=graphics;
x=MenuX;
y=MenuY;
num=number;
/**
*开始画咯,这里可以修改颜色,或者你设置自己的字体
*g.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_SMALL));方法都给你了
*起始地址还没写,默认0,0
*/
//先清屏
g.setColor(0xffffff);
g.fillRect(0,0,getWidth(),getHeight());
g.setColor(0xff00ff);
for(int i=0;i<num;i++){
g.drawRect(0,0+y*i,x,y);
}
/**
*传进来的菜单项目,简单点说就是有多少格,五格以上就免了,那样还要写一个更加广泛的涵数,现在没空
*写上每格的字
*/
g.setColor(0X333333);
switch(num)
&n......
J2ME 拯救大兵(2006-11-30 18:28:00)
摘要://img3.png
//img2.png
//img1.png
//tree.png
//man.png
/*
*http://blog.programfan.com/blog.asp?author=qq14923349
*程序之巢制作 @J2ME计时器@
*如果有图片
*图片存在rec目录下,记得在存之前把格式转换成png,具体方法是:
1,点击开始
2,附件
3,图画板
4,打开图片
5,另存为(可以存作PNG了,不要直接改后续名,否则运行不了)
6,其他工具,可以选用PS,或者ACDSEE等等改
*/
/*
人肉小炒(418138484) (2006-12-02 12:34:54)
没有菜单
没有帮助
没有退出游戏
没有关卡
寻路太差
可控人物跟npc没有明显区分
玩了一会居然跑到屏幕外面去了
*/
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.*;
import java.util.*;
public class Saver extends MIDlet
{
private SaverCanvas savercanvas;
public void startApp(){
savercanvas=new SaverCanvas(Display.getDisplay(this));
savercanvas.start();
}
public void pauseApp(){}
public void destroyApp(boolean e......
J2ME Xman.jar(2006-11-11 09:36:00)
摘要://man.png
//background.png
/*
*http://blog.programfan.com/blog.asp?author=qq14923349
*程序之巢制作,移动窗口TiledLayr类例子
*图片存在rec目录下,记得在存之前把格式转换成png,具体方法是:
1,点击开始
2,附件
3,图画板
4,打开图片
5,另存为(可以存作PNG了,不要改后续名,否则运行不了)
6,其他工具,可以选用PS,或者ACDSEE等等改
*/
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.*;
public class Xman extends MIDlet
{
public void startApp(){
new Man1(Display.getDisplay(this)).start();
}
public void pauseApp(){}
public void destroyApp(boolean e){}
class Man1 extends GameCanvas implements Runnable{
private Display display;
private Sprite xman;
private TiledLayer background;
private int Xbackground,Ybackground;
public Man1(Display d){
super(true);
......
J2ME游戏 XX就下一百层(建立了模)(2006-10-07 18:56:00)
摘要://说明一下,JPG格式记得用画图板转换为PNG格式否则,嘿嘿```
//009-Lancer01.png
//007-Swamp01.png
//001-Sky01.PNG
import javax.microedition.midlet.MIDlet;
import javax.microedition.rms.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.util.*;
import java.io.*;
//简单的动画canvas by sword2008@程序之巢
public class test2 extends MIDlet{
private Display display;
public test2(){
}
public void startApp(){
new test(Display.getDisplay(this)).start();}
public void pauseApp(){ }
public void destroyApp(boolean unkowmn){ }
class test extends GameCanvas implements Runnable
{
//////////////////////////////////////
private Display display;
private long frameDelay;
private boolean sleeping;//游戏终止或者停止
private Random rand;
private Sprite ken;
private int XSpeed,YSpeed,treeYSpeed=-7;
private Sprite tree[]=new Sprite[5];
&n......
J2ME 准备做个是XX就下一百层1(代码混乱)(2006-09-23 14:44:00)
摘要:import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import java.util.*;
import java.io.*;
//简单的动画canvas by sword2008@程序之巢
//我原本的图片有张超过了200k,传不上来。
public class test2 extends MIDlet{
private Display display;
public test2(){
}
public void startApp(){
new test(Display.getDisplay(this)).start();}
public void pauseApp(){ }
public void destroyApp(boolean unkowmn){ }
class test extends GameCanvas implements Runnable
{
//////////////////////////////////////
private Display display;
private long frameDelay;
private boolean sleeping;
private Random rand;
private Sprite ken,ken2,ken3;
private int XSpeed,YSpeed,treeYSpeed=-3;
private Sprite tree[]=new Sprite[5];
private TiledLayer backgroundLayer,backgroundLayer2;
private char sp;
private boolean l......
[原创]J2ME 移动的格子(2006-08-28 10:02:00)
摘要:import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
//made by sword2008·程序之巢
//游戏第一课 画格子
public class Gofirst1 extends MIDlet
{
public Gofirst1(){
}
public void startApp(){
Display.getDisplay(this).setCurrent(new First1());
}
public void pauseApp(){}
public void destroyApp(boolean unkown){}
}
class First1 extends Canvas
{ private int color;
private int forOneTime=0;
private Graphics g;
private int startX=getWidth()/4-40;//起点坐标和终点坐标非常重要,格子剩下的是分成等分
private int startY=getHeight()/4-40;
private int nowX=startX,nowY=startY;
public void paint(Graphics g){
if(forOneTime==0){
color=g.getColor();
g.setColor(255,255,255);
g.fillRe......
[原创]初学问题去掉String中的空格(2006-04-28 10:54:00)
摘要:本贴不断更新中
相信大家都会碰到这类问题吧:
public class test1{
public static void main(String args[]){
int cont;
cont=Integer.parseInt(" 11".);//讨厌的空格
System.out.println(cont);
}
}
但是加个trim() 就可以去掉空格了!
public class test1{
public static void main(String args[]){
int cont;
cont=Integer.parseInt(" 11".trim() );//空再多也没所谓了!
System.out.println(cont);
}
}......
计算器未完成的试验1(1+2可以算)(2006-04-25 11:31:00)
摘要:import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class test extends JFrame{
static int count=0;
private JLabel promptLabel;
private JTextField inputField;
private JTextArea outputArea;
private JButton j0,j1,j2,j3,j4,j5,j6,j7,j8,j9,x1,x2,y1,y2,s1,s2;
private int all=0,jiahao=0,j11,j22;
public test(){
super("ceshi StringTokenizer");
Container container=getContentPane();
container.setLayout(new FlowLayout());
promptLabel=new JLabel("计算器");
container.add(promptLabel);
inputField=new JTextField(20);
inputField.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
Stri......
java GUI小程序(2006-04-08 17:29:00)
摘要:import java.awt.*;
import javax.swing.*;
public class ColorAndLine extends JFrame{
public ColorAndLine(){
super("using color and line");
setSize(800,400);
setVisible(true);
}
public void paint(Graphics g){
super.paint(g);
while(true)
{//System.out.print((int)(Math.random()*100));
g.setColor(new Color((int)(Math.random()*250),(int)(Math.random()*250),(int)(Math.random()*250)));
g.drawLine((int)(Math.random()*1000),(int)(Math.random()*1000),(int)(Math.random()*100),(int)(Math.random()*100));
repaint();
}
}
public static void main(String args[]){
ColorAndLine application=new ColorAndLine();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
修改
import java.awt.*;
import javax.swing.*;
public class ColorAndLine extends JFram......