Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I make a MenuScene when my Game loads, which grabs some intro text from levelData and displays it and a button to start playing the level. When the MenuScene is created and displayed in onLoadComplete() it's fine. However when I display it again when advancing the level (levelData is loaded with new data and the MenuScene reset) it freezes, showing the game at the point the level was beaten. The menu is not displayed at all. I'm just calling

this.mScene.setChildScene(this.mIntroScene, false, true, true);

to display the MenuScene (the same both times, it works the first time but not the second), where loadIntro() is

private void loadIntro() {
            this.mIntroScene = new MenuScene(this.mCamera);

            final TextMenuItem intro = new TextMenuItem(-1, mFont, levelData.getIntroText());
            intro.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
            intro.setSize(400, 150);

            final SpriteMenuItem startMenuItem = new SpriteMenuItem(MENU_START, this.mMenuStartTextureRegion);
            startMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);



What am I doing wrong?

share|improve this question
Have you run through the code with a debugger? Do you know where the problem is? My guess is that something is not be initialised properly. – thedaian Aug 24 '11 at 23:11
Is it possible to use a separate thread for the game action? I'm wondering if the menu being activated is consuming the current thread (this is only a guess). – Randolf Richardson Aug 25 '11 at 2:37
@Randolf rewriting into a separate thread fixed it, write up an answer so I can accept it! – fredley Aug 25 '11 at 10:46
up vote 4 down vote accepted

Is it possible to use a separate thread for the game action? I'm wondering if the menu being activated is consuming the current thread (this is a guess based on my experience in programming applications in Java that use menus).

I suspect that what's going on is that you have one main thread, and that by activating the menu your code is temporarily halted while the user decides what to do with the menu.

share|improve this answer

Your Answer


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.