Well I've finnaly decided to start Android game dev, and my first project will be simple 2d canvas based game. I have some experience in game developing with C# and XNA, and I'm a bit confused now. Back in XNA we have Game class with Initialize, Update and Draw methods.

In Android I have to extend SurfaceView class, run draw and update in their own thread, and receive touch input from user.

I'm looking for a proper way to structure my code.

Some of my questions are :

  • How to deal with Activities (Should I run everything in one activity, or split whole game in 2 or more) ?
  • Where should I run game loop ?
  • Where to put Draw and Update methods ?
  • How to respond to touch events ?

Hope I came to the right place for answers...

  • 1
    \$\begingroup\$ I suggest you want to look at LibGDX. Just like XNA it's a library for games. It has a pretty big community and lots of documentations. \$\endgroup\$ – Sidar Jan 6 '13 at 4:20
  • \$\begingroup\$ Well, I'll give it a try sometime. \$\endgroup\$ – Nikola Ninkovic Jan 6 '13 at 10:13

A minimal Breakout game, demonstrating the use of Activities, touch event handling, and draw/update with GLSurfaceView can be found here.

| improve this answer | |
  • \$\begingroup\$ Google Code is being discontinued, and the project has been moved to Github. Here's the repository. \$\endgroup\$ – beatgammit Aug 28 '16 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.