Java新手,今天在学写一个打飞机的小游戏,遇到一处不明
public class PPlane extends Plane{private Image img;
private JPanel jpanel;
private int direction;
public static boolean UP;
public static boolean DOWN;
public static boolean LEFT;
public static boolean RIGHT;
public static boolean isFired;
public static int life = 100;
public PPlane(){
}
public PPlane(int x, int y, int width, int height) {
super(x, y, width, height);
img = new ImageIcon("Image/boss1.png").getImage();
// TODO Auto-generated constructor stub
}
//传递 画布 这里是什么意思?
public JPanel getJpanel() {
return jpanel;
}
//还有这里
public void setJpanel(JPanel jpanel) {
this.jpanel = jpanel;
}
//设置方向
public int getDirection() {
return direction;
}
public void setDirection(int direction) {
this.direction = direction;
}
public void drawMe(Graphics g) {
// TODO Auto-generated method stub
g.drawImage(img, this.x,this.y,this.w,this.h,this.jpanel);
}
public void changeDirection(int direction){
this.direction = direction;
}
public void pplaneMove(){
if (UP)
y -= Global.SPEED;
if (DOWN)
y += Global.SPEED;
if (LEFT)
x -= Global.SPEED;
if (RIGHT)
x += Global.SPEED;
}
public boolean isAlive(){
if(PPlane.life <= 0){
PPlane.life = 0;
return false;
}
else
return true;
}
}
[ 本帖最后由 墨落成白 于 2015-3-15 10:11 编辑 ]