📄 bullet.java~10~
字号:
package newgame;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class Bullet extends Base {
int speedx, speedy; //速度
Image img;
Image shadow;
int frameWidth, frameHeight;
Tools tool;
boolean visble; //可见不可见
int x, y; //坐标
int type; //类型
Canvas1 mc;
final int hero = 1;
final int enemy = 2;
final int boss = 3;
/**
switch (type) {
case hero:
break;
case enemy:
break;
case boss:
break;
}*/
public Bullet(Canvas1 mc, int type) {
tool = new Tools(this.mc);
this.mc = mc;
this.type = type;
switch (type) {
case hero:
img = tool.getImage("/ammo.png");
break;
case enemy:
break;
case boss:
break;
}
}
public void setPosition(int x, int y) {
this.x = x;
this.y = y;
switch (type) {
case hero:
speedy = -7;
break;
case enemy:
break;
case boss:
break;
}
this.setVisble(true);
}
public void move() {
switch (type) {
case hero:
this.x += speedx;
this.y += speedy;
break;
case enemy:
break;
case boss:
break;
}
}
public void paint(Graphics g) {
if (this.isVisble()) {
g.drawImage(img, x, y, g.LEFT | g.TOP);
}
}
public void setVisble(boolean flag) {
this.visble = flag;
}
public boolean isVisble() {
return this.visble;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -