Game framework

Problems with Canvas, OpenGL, etc...

Game framework

Postby Defero » Wed Dec 07, 2011 3:07 am

Hi,

so i have been searching for an answer for a while now, but no luck.
I'm new to this and i'm wondering is there an elegant way to do different screens in code.

Ive seen examples where they create a new Intent and then start the activity from a class which divides the code quite nicely.

So you can start the "options" screen activity or "about" or "start"...
I have i problem that i want for all this screens to be animated, menu too, where i use a thread.

The question is, is there a nice way to divide this now or do i have to use a switch statement in the thread and switch there what is drawn?

Thank you for all your help in advance.
Defero
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Dec 07, 2011 3:05 am

Top

Re: Game framework

Postby MichaelEGR » Wed Dec 07, 2011 9:41 pm

Defero wrote:Ive seen examples where they create a new Intent and then start the activity from a class which divides the code quite nicely.


This is known as the dashboard UI pattern. The Facebook, Yelp, and many apps use this pattern. Sure it can be used for a game, but consider that separating your app this way and hard locking things to the Activity lifecycle could make it harder to port it to other platforms. But don't let cross-platform concerns stop you now since it sounds like your just getting started and you'll be working with Android for a bit.

Defero wrote:So you can start the "options" screen activity or "about" or "start"...
I have i problem that i want for all this screens to be animated, menu too, where i use a thread.
The question is, is there a nice way to divide this now or do i have to use a switch statement in the thread and switch there what is drawn?


Indeed. I'd recommend creating some sort of rendering interface and have one or a list of renderers that has an update method that receives the current time and such. You'll want to avoid conditional statements if/switch in a render loop if possible otherwise things will be very static. You can schedule changes to the order of the renderers in the loop too as potentially one time runnables that execute at the beginning of the loop thus removing the necessity of conditional statements in the loop itself. Conceivably this is how you can switch game states whether that is a menu or something else.

I'm soon releasing a real time app / game dev platform for Android called TyphonRT. What I do is have a clocking thread that is at the Application level and is shared between Activities such that when a new Activity starts it may immediately attach to the clocking thread for animation / updates. This is useful for whatever graphics API used (Android 2D or OpenGL ES). Drop me a note at the contact email and I'll keep you posted.
Founder & Principal Architect; EGR Software LLC
http://www.typhonrt.org
http://www.egrsoftware.com
User avatar
MichaelEGR
Senior Developer
Senior Developer
 
Posts: 147
Joined: Thu Jan 21, 2010 5:30 am
Location: San Francisco, CA

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 1 guest