Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Andengine onScreen Pause button

I want to create an onscreen pause button in andengine

What I do now is add an sprite and when I touch it, I do engine.stop(), the problem with this, is that the engine doesn't handle more touchevents till I resume the game (now I use the menu button for this), so is there a way to achieve it?

Thanks!

like image 846
Jordi Puigdellívol Avatar asked Mar 02 '26 04:03

Jordi Puigdellívol


2 Answers

Look at the AndEngine's examples, there is a project that shows the use of menus in AndEngine, you'll find a better way of implementing a menu other than stopping the engine. Good luck!

like image 187
Egor Avatar answered Mar 04 '26 17:03

Egor


I found the best way to do it is creating an scene, and when paused, set override the onManagedUpdate this way

@Override
onManagedUpdate(float pSecondsElapsed){
 if(mPaused) super.onManagedUpdate(0);
 else        super.onManagedUpdate(pSecondsElapsed);
}

This way everything works perfectly, and you can do it on a game layer and have the menu layer updated as usual,

like image 41
Jordi Puigdellívol Avatar answered Mar 04 '26 17:03

Jordi Puigdellívol