⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 people.java

📁 自己写的JAVA飞机飞行游戏
💻 JAVA
字号:
package FightChess;
//Download by http://www.codefans.net
import javax.microedition.lcdui.game.*;
import javax.microedition.lcdui.Image;
public class People extends Sprite
{
	public static final int UP = 0;
	public static final int DOWN = 1;
	public static final int LEFT = 2;
	public static final int RIGHT = 3;
	private int[][] moveFrame;
	private int moveSpeed=4;
	protected int frameIndex = 0;
	protected int direction = UP;
	private TiledLayer barrierLayer=null;
	public People(Image img,int width,int height,int [][] move)
	{
		super(img,width,height);
		moveFrame = move;
	}
	public void setBarrierLayer(TiledLayer bLayer)
	{
		barrierLayer = bLayer;
	}
	public void moveStop()
	{
		frameIndex = 0;
		setFrame(moveFrame[direction][0]);
	}
	private void setMoveFrame()
	{
		if(moveFrame==null||moveFrame[direction].length<=1)return;
		setFrame(moveFrame[direction][frameIndex++]);
		if(frameIndex>=moveFrame[direction].length)frameIndex = 0;
	}
	public void moveLeft()
	{
		direction = LEFT;
		setMoveFrame();
		move(-moveSpeed,0);
		if(collidesWith(barrierLayer,false))move(moveSpeed,0);
	}
	public void moveRight()
	{
		direction = RIGHT;
		setMoveFrame();
		move(moveSpeed,0);
		if(collidesWith(barrierLayer,false))move(-moveSpeed,0);
	}
	public void moveUp()
	{
		direction = UP;
		setMoveFrame();
		move(0,-moveSpeed);
		if(collidesWith(barrierLayer,false))move(0,moveSpeed);
	}
	public void moveDown()
	{
		direction = DOWN;
		setMoveFrame();
		move(0,moveSpeed);
		if(collidesWith(barrierLayer,false))move(0,-moveSpeed);
	}
}

⌨️ 快捷键说明

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