📄 plane.java
字号:
package npc7776;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
public class Plane {
Image img;
int x , y;
int frameX, frameY;
int scnX , scnY;
Sprite plane;
int Move = 3;
boolean b = true;
public Plane(Image imgs,int fX,int fY,int sX,int sY) {
scnX = sX; //屏幕宽
scnY = sY; //屏幕高
frameX = fX; //桢数
frameY = fY;
img = imgs;
x = y = sX /2 ;
plane = new Sprite(img,frameX,frameY);// 构造plane
}
// 画飞机
public void drawSelf(Graphics g){
if (b == true){
plane.setPosition(x,y) ;
plane.paint(g) ;
b = false;
}else
plane.paint(g) ;
}
public void hf(){
plane.setFrame(0);}
//移动左方法
public void moveLeft(){
getXY();
plane.setFrame(1) ;
if (x - Move > 0){
plane.move(-Move,0) ;
}
}
public void moveRight(){
getXY();
plane.setFrame(2) ;
if (x + Move + frameX < scnX){
plane.move(Move,0) ;
}
}
public void moveUp(){
getXY();
plane.setFrame(0) ;
if (y - Move >0){
plane.move(0,-Move) ;
}
}
public void moveDown(){
getXY();
plane.setFrame(0) ;
if (y+frameY+Move < scnY){
plane.move(0,Move) ;
}
}
//获得飞机 X,Y 点
public void getXY(){
x = plane.getX() ;
y = plane.getY() ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -