laster吧 关注:2贴子:33
  • 1回复贴,共1

AAAAA

收藏回复

  • 113.14.252.*
import javax.microedition.lcdui.game.*;
import javax.microedition.lcdui.*;
public class BallCanvas extends GameCanvas implements Runnable
{
     int x;
     int y;
     int vx;
     int vy;
     Graphics g;
     public BallCanvas()
     {
         super(false);
         x = 0;
         y = 0;
         vy = 1;
         vx = 1;
         setFullScreenMode(true);
         g = this.getGraphics();
     }
     public void run()
     {
         if ((x > 100) | (x < 0))
         {
             vx = -vx;
         }
         if ((y > 100) | (y < 0))
         {
             vy = -vy;
         }
         vx += vx;
         vy += vy;
         g.fillRect(20, 20, 20, 20);
         try
         {
             Thread.sleep(150);
         }
         catch(Exception e)
         {
         }
     }
}
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Ball extends MIDlet
{
     Display dis;
     BallCanvas mainCanvas;
     public Ball()
     {
         dis = Display.getDisplay(this);
         mainCanvas = new BallCanvas();
     }
     public void startApp()
     {
         System.out.println("START");
         Thread t = new Thread(mainCanvas);
     }
     public void pauseApp()
     {
         System.out.println("PAUSE");
     }
     public void destroyApp(boolean b)
     {
         System.out.println("CANCEL");
     }
}


1楼2009-12-18 15:08回复
    我是神!


    删除|2楼2010-08-14 16:02
    回复