Zach H
Zach H

Reputation: 257

Is it better to use Android's built-in frame-by-frame animation methods or create your own?

I have downloaded several example Android games, and most of them do not use Android's animation methods. I have also seen several posts on this site and other sites where some say that they prefer not to use Android's animation methods, but they never explain why.

So, is it generally better not to use Android's animations for games?

Upvotes: 4

Views: 311

Answers (1)

MusicMaster
MusicMaster

Reputation: 549

I would not recommend using Android's Animation classes for games. The reason is that they operate on Views which are not lightweight enough for the high performance games require. Views are designed for buttons, text, and images that mostly stay still, positioned in organized layouts, and not for images that move all over the place. The two best approaches for making games with Android are:

  • Using the Canvas class. Note that this will only work for simple 2-D sprite-based games, as it tends to be quite slow. It's relatively easy for beginners to learn.

  • Using OpenGL ES. This works for pretty much any game - it's fast and can do both 2-D and 3-D games. Be warned, it is very complicated and I would not recommend beginners use OpenGL ES!

If you are new to programming games, I would recommend buying a book on the topic such as Mario Zechner's excellent book "Beginning Android Games" (look for it on Amazon). This book starts by making a "Snake" clone using Canvas, then walks through the basics of OpenGL and shows you how to make a 2-D "Doodle Jump"-like game, then transitions into 3-D by making a 3-D "Space Invaders" app. I highly recommend this book, it explains everything really clearly, is not a boring read, and is what I used to make my first game on Android.

Hope that helps!

EDIT:

There is a third option for making games for Android: using a pre-built game library. These libraries provide the advantage of speed by being based OpenGL but are much easier to use. Many are also cross-platform, meaning your code will be easier to port to other operating systems such as iOS. (Keep in mind that cross-platform solutions are not always ideal, though.) Examples of game free libraries include Cocos2D and libGDX. If you do choose to go down this path, make sure to follow the licence agreement (this may involve putting some sort of logo on the main screen).

These libraries are good and provide an easy entry into game development, but keep in mind that creating a game from scratch will provide knowledge and a sense of accomplishment you won't get anywhere else.

Upvotes: 2

Related Questions