3
我用這TimerHandler在andEngine產卵在特定的時間精靈..TimerHandler在andengine spawing精靈在間隔
mScene.registerUpdateHandler(new TimerHandler(0.02f, true, new ITimerCallback() {
@Override
public void onTimePassed(TimerHandler pTimerHandler) {
addSpriteTime1 += 2; // because timer update = 0.02 seconds
if (addSpriteTime1 == nextSprite1Time) {
addFace();
addSpriteTime1 = 0;
}
addSpriteTime2 += 2;
if (addSpriteTime2 == nextSprite2Time) {
addFace2();
addSpriteTime2 = 0;
}
addSpriteTime3 += 2;
if (addSpriteTime3 == nextSprite3Time) {
addFace3();
addSpriteTime3 = 0;
}
}
}));
現在我已經在類級別聲明INT變量..
private int nextSprite1Time = 100;// initial value, could be changed during game
private int nextSprite2Time = 100;
private int nextSprite3Time = 100;
然後我有一個方法可以讓我改變速度或nextSpriteTimes。
private void speed(int f, int g, int h){
this.nextSprite1Time = f;
this.nextSprite2Time = g;
this.nextSprite3Time = h;
Log.e("Time Changed", String.valueOf(this.nextSprite1Time+ "," + this.nextSprite2Time + ","+ this.nextSprite3Time));
}
問題是,當我試圖改變例如速度..
speed(30, 50, 70);
它只是停止所有一起,現在精靈加入,
有誰看到我要去的地方這個錯誤還是可以做到這一點?