📄 herobullet.java~5~
字号:
package newgame;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class HeroBullet 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 hero1_1 = 1;
final int hero1_2 = 4;
final int hero2_1= 2;
final int hero3_1= 3;
int frameCntX; //子弹图片X指针
int frameCntY; //子弹图片Y指针
public HeroBullet(Canvas1 mc, int type) {
this.mc = mc;
tool = new Tools(this.mc);
this.type = type;
switch (type) {
case hero1_1:
img = tool.getImage("/H1_bullet.png");
break;
case hero2_1:
img = tool.getImage("/H2_bullet.png");
break;
case hero3_1:
img = tool.getImage("/H3_bullet.png");
break;
}
}
public void setPosition(int x, int y) {
this.x = x;
this.y = y;
switch (type) {
case hero1_1:
speedy = -7;
break;
case hero2_1:
break;
case hero3_1:
break;
}
this.setVisble(true);
}
public void move() {
switch (type) {
case hero1_1:
this.y += speedy;
break;
case hero2_1:
break;
case hero3_1:
break;
}
}
public void paint(Graphics g) {
if (this.isVisble()) {
tool.drawPartImage(g,img,this.mc.hero.x+3+x,this.mc.hero.y-5+y,frameCntX*15,frameCntY*24,15,24);
}
}
public void setVisble(boolean flag) {
this.visble = flag;
}
public boolean isVisble() {
return this.visble;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -