Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

Are you still having the problem? Try checking out the AndEngine example for the pause menu

if(this.mEngine.isRunning()) {
        this.mMainScene.setChildScene(this.mPauseScene, false, true, true);
        this.mEngine.stop();
} 
else {
        this.mMainScene.clearChildScene();
        this.mEngine.start();
}

The above code should work for a pause menu.

share|improve this answer
1  
In that example, the touch event of the pause button was not implemented and I want that touch event implementation. The engine was stopped so no touch event is possible that was my problem. In that particular example all the thing was handle using menu button of the device. But I don't want that implementation. –  Siddharth Aug 4 '12 at 5:12

I used

engine.getSoundManager().onPause();
parentScene.setIgnoreUpdate(true);

and

engine.getSoundManager().onResume();
parentScene.setIgnoreUpdate(false);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.