player.java

来自「J2ME虚拟机在手机上的普及为手机游戏的发展提供了最适合的土壤」· Java 代码 · 共 50 行

JAVA
50
字号
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

public class Player extends Sprite
{ 
  
  protected static final int RAW_FRAMES=1;
  protected static int xPos;
  protected static int yPos;  
  protected static VaderCanvas gameCanvas;
  protected static VaderManager layerManager;

  public Player(Image image, int width, int height, int xPos, int yPos)
  {
    super (image,width,height);
    this.yPos=yPos;
    this.xPos=xPos;
    setPosition(xPos, yPos);
    gameCanvas=layerManager.getGameCanvas();
  }
  
  public static void setLayerManager(VaderManager manager)		{layerManager=manager;}

  public void setY(int y)				{setPosition(this.getX(),this.getY()+y);}
  
  public void left()
  {
    if(this.getX()>0)
    {
    	move(-2,0);
    }
    
	// TO DO create a sense of momentum for the UIQ jog dial input method.


  }
  public void right()
  {
    if((this.getX()+getWidth())<=gameCanvas.getWidth())
    {
    	move(2,0);
    }
    
    // TO DO create a sense of momentum for the UIQ jog dial input method.
  }	
  public void fire()
  {
  	layerManager.initBullets();  	
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?