Android: how do I switch between game scenes in a game? Any tutorials?
Posted
by
Flavio
on Game Development
See other posts from Game Development
or by Flavio
Published on 2012-04-05T06:21:09Z
Indexed on
2012/04/05
11:44 UTC
Read the original article
Hit count: 285
android
I am trying to create a simple game using the Android SDK without using AndEngine (or any other game engine). I have plenty of experience designing games from the past, but I'm having lots of trouble trying to use the Android SDK to make my game. By far my biggest hurdle right now is switching between views. That is, for example, going from the menu to the first level, etc.
I am using a traditional model I learned (I think it's called a scene stack or something?) in which you push the current scene onto a stack and the game's main loop runs the top item of the stack. This model seems non-trivial to implement in the Android SDK, mostly because Android seems to be picky about which thread instantiates which view. My issue is that I want the first level to show up when you press a button on the main menu, but when I instantiate the first level (the level class extends SurfaceView and implements SurfaceHolder.Callback) I get a runtime error complaining that the thread that runs the main menu can't instantiate this class. Something about calling Looper.prepare(). I figured at this point I was probably doing things wrong.
I'm not sure how to specifically phrase my issue into a question, so maybe I should leave it as either
1) Does anybody know a good way (or the 'proper' way) to switch between scenes in an Android game?
or
2) Are there any tutorials out there which show how to create a game that doesn't take place entirely in one scene? (I have googled for a while to no avail... maybe someone else knows of one?)
Thanks!
© Game Development or respective owner