Be77amy
Be77amy

Reputation: 45

is multiple activities and surface views the correct way to go?

I'm currently in the process of making one of my first android games and have come into some difficulty understanding how to make the transitions between screens.. for example:

My game starts its main activity, which then loads TitleScreen surface view which initializes its own thread

on tap I start a new intent which loads a new activity which loads GameView surface view which initializes its own thread

This all works fine when testing on my device (Evo 3d) but crashes on tap on my test bed, I'm using android x86 in virtual box for quick testing. Is this likely to be a problem in my code or a problem with the simulator?

Also I'm wanting to add a level select screen in between the title screen and the game screen and figured i could do this by creating another activity/surface view/thread combo, Is this acceptable coding practice or is this a wasteful/process heavy method?

Upvotes: 0

Views: 570

Answers (2)

NikkyD
NikkyD

Reputation: 2284

You could create a variety of methods that you call from your onDraw method. Each method would draw one screen (game, level, score). To start simple a switch case in the onDraw checks the screen and then calls the right thing to draw.

If you want to have different layers, you should use different acitvities so that the background (game) is being paused while the scoreboard is active. This only makes sense if you want the background to be still visible or need the acitivites for other reasons.

But you should never have more than one surface view active at the same time, android doesnt like that.

Upvotes: 1

Yugandhar Babu
Yugandhar Babu

Reputation: 10349

I think its not good to use more activities for single application. Try to use ViewFlipper with number of xml layout files. Here you can apply transition effects very easily.

I am suggesting you it for transition effects, but you also check it once. I am also thinking which one is good.

Upvotes: 0

Related Questions