我正在用andengine开发一个游戏。我有玩家。有一些敌人会随着MoveModifier随机出现,它们是精灵。我想要:plyer射出子弹,子弹接触敌人,敌人将是隐形的。如何我可不可以做?
子弹
private Runnable mStartCircle1 = new Runnable() {
public void run() {
final Scene scene= HelicopterActivity.this.mEngine.getScene();
float velocityOfCircleC=1.6f;
float startXC=player.getX()+50;
float finishXC=800;
float startYC=player.getY()+15;
float finishYC=startYC;
bullet=new Sprite(startXC, startYC, HelicopterActivity.this.gasTextureRegion);
bullet.registerEntityModifier(
(IEntityModifier) new SequenceEntityModifier (
new MoveModifier(velocityOfCircleC, bullet.getX(), finishXC, bullet.getY(), finishYC)));
scene.attachChild(bullet);
敌人
int j=0, k=0;
private Runnable mStartCircle = new Runnable() {
public void run() {
final Scene scene= HelicopterActivity.this.mEngine.getScene();
float startY=randomNumber.nextInt(670 - 1);
float velocityOfCircle=6;
enemy[j] = new Sprite( 800, startY, HelicopterActivity.this.enemyTextureRegion);
enemy[j].registerEntityModifier(
(IEntityModifier) new SequenceEntityModifier (
new MoveModifier(velocityOfCircle, enemy[j].getX(), -128,
enemy[j].getY(), enemy[j].getY())));
scene.attachChild(enemy[j]);
float startY2=randomNumber.nextInt(670 - 1);
float velocityOfCircle2=10;
enemy2[k] = new Sprite( 800, startY2, HelicopterActivity.this.enemy2TextureRegion);
enemy2[k].registerEntityModifier(
(IEntityModifier) new SequenceEntityModifier (
new MoveModifier(velocityOfCircle2, enemy2[k].getX(), -128,
enemy2[k].getY(), enemy2[k].getY())));
scene.attachChild(enemy2[k]);
k++;
j++;
if (k<50){
mHandler.postDelayed(mStartCircle,5000);
}
}};
if (i<1000){
mHandler.postDelayed(mStartCircle1,1000);
}
}};