How do I set a touch listener in a child scene in AndEngine?
- by Siddharth
In my game, I want to implement touch listener for my child scene objects. Basically I tried all the possible way to implement this that I have usually done for my normal scenes, but those methods do not work here. Could somebody provide some guidance for setting touch area listener in child scene?
Here is my code:
menuScene.setTouchAreaBindingEnabled(true);
menuScene.registerTouchArea(resumeButtonSprite);
menuScene.registerTouchArea(retryButtonSprite);
menuScene.registerTouchArea(exitButtonSprite);
menuScene.setOnAreaTouchListener(new IOnAreaTouchListener() {
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
ITouchArea pTouchArea, float pTouchAreaLocalX,
float pTouchAreaLocalY) {
System.out.println("Touch");
return true;
}
});
In this code, menuScene was a child scene activity.
Also after research I found that my engine was stopped while the child scene was activated so the touch event is not detected. I want to implement a pause menu in my game so any desirable solution for a pause menu implementation would help.