📄 zonbullet.java
字号:
package zonja;
import java.io.DataInputStream;
import java.io.DataOutputStream;
public class ZonBullet extends ZonSprite {
public ZonBullet(int scrWidth, int scrHeight) {
super(scrWidth, scrHeight);
setRealSize(12, 12);
}
private int timer = 0;
private static final int BULLET_SPEED = 3;
public boolean saveData(DataOutputStream dos){
if(!super.saveData(dos))
return false;
try {
dos.writeInt(timer);
}
catch(Exception e) {
return false;
}
return true;
}
public boolean loadData(DataInputStream dis){
if(!super.loadData(dis))
return false;
try {
timer = dis.readInt();
}
catch(Exception e) {
return false;
}
return true;
}
void mainAction() {
if(offsetX < -16 && offsetX > scrWidth){
isVisible = false;
}
if(isVisible){
if(timer++ < 10){
if(moveDirection == MOVEDIRECTION_LEFT)
hVelocity = -BULLET_SPEED;
else
hVelocity = BULLET_SPEED;
if(timer > 3 && timer <= 7)
frameIndex = 1;
else if(timer > 7 && timer < 9)
frameIndex = 2;
}else{
timer = 0;
isVisible = false;
}
move(hVelocity, 0);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -