This is not an efficient way to do it, not for 2D games, and not for
3D games. I'll explain:

For 2D games like you describe, you do need layers, but putting each
layer in its on view is wasteful, specifically in terms of
performance, since the Android framework has to manage the life-cycles
of all of them, and there's quite a lot of code running behind the
scenes for each one.

Other alternative examples are:
1. Redrawing the entire view, including the background on each frame -
on a single view
2. Drawing each layer into a bitmap, and then drawing all those
bitmaps to the (single) view on each frame
3. Optimizations can be done by redrawing only dirty-regions (for
example)

If you want to write high-performance games, you definitely need to
use SurfaceView, and not a regular view.

For OpenGL games, you can use the basic GLSurfaceView, and here as
well, you need to redraw the entire frame - every frame (Of course
there are all kinds of optimizations like back-face culling, clipping,
etc.)

If you want to create a 2D game using OpenGL, you can do it by
creating a 2D projection matrix (Here's a good tutorial:
http://basic4gl.wikispaces.com/2D+Drawing+in+OpenGL, note that not all
gl-commands mentioned are compatible with OpenGL ES - So you can't
just copy/paste this into your code, but explains the principles well)

Here's the best resource to get you started:
http://code.google.com/events/io/2009/sessions/WritingRealTimeGamesAndroid.html

Lior Gonnen
UltimateFaves / UltimateFavesPRO developer
http://ultimatefaves.wordpress.com/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to