Reloading Resources on Resume

Posted by Siddharth on Game Development See other posts from Game Development or by Siddharth
Published on 2013-06-25T16:39:36Z Indexed on 2013/06/25 22:30 UTC
Read the original article Hit count: 275

Filed under:

I'm having a problem with my game. If I press the "Home button" the game is paused... everythings fine, but if I then go back to the game all the resources are reloaded before I can continue the game. And it takes quite a bit. Is this normal, or is there a way to avoid the reloading?

I have write following code in onResume and onPause method. It loads same texture again and again on resume of game.

    @Override
    protected void onPause() {

            super.onPause();
            if (Utility.flagSound && mScene != null) {

                    if (mScene.getUserData().equals(Constants.GAME_SCENE))
                            Utility.isPlayLevelMusic = false;
                    else
                            Utility.isPlayLevelMusic = true;

                    audioManager.gameBgMusic.pause();
                    audioManager.levelBgMusic.pause();
            }

            if (this.mEngine != null && this.mEngine.isRunning()) {
                    this.mEngine.stop();
            }

    }

    @Override
    protected void onResume() {

            super.onResume();
            if (audioManager != null && Utility.flagSound && dataManager != null) {
                    if (Utility.flagSound) {
                            if (Utility.isPlayLevelMusic)
                                    audioManager.levelBgMusic.play();
                            else
                                    audioManager.gameBgMusic.play();
                    }
            }

            if (this.mEngine != null && !this.mEngine.isRunning()) {
                    this.mEngine.start();
            }

    }

I would be glad if anybody could help...

© Game Development or respective owner

Related posts about andengine