0
我有精靈(精靈1)和倒數計時器,我想知道是否有辦法讓引擎啓動倒數計時器只有當精靈被感動。如何在觸摸精靈時啓動倒數計時器
Sprite sprite1;
int time=10;
@Override
public void onPopulateScene(Scene pScene,
OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
sprite1= new Sprite(100, 100, squarer, this.mEngine.getVertexBufferObjectManager())
{
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float X, float Y)
{
scene.setBackground(new Background(200,200,200));
}
};
TimerHandler mtimer= new TimerHandler(0.1f,true,new ITimerCallback() {
@Override
public void onTimePassed(TimerHandler pTimerHandler) {
// TODO Auto-generated method stub
time--;
if (time==0){
scene.setBackground(new Background(0,0,120));
}
}
});
this.scene.attachChild(sprite1);
this.scene.registerTouchArea(sprite1);
this.scene.registerUpdateHandler(mtimer);
pOnPopulateSceneCallback.onPopulateSceneFinished();
}
}
我怎麼叫計時器,然後,你可以請給我一個例子關於如何去做 – user3661470