I have a sprite(sprite1), and a countdown timer, and I wanted to know if there is a way to have andengine start the countdown timer ONLY when the sprite is touched.
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();
}
}