Use of Wakelok and Stand-By in Android Games

When to suppress the Stand-By Mode in Games?

This depends on the kind of game you want to develop. If the player has to interact with the game constantly or if he only has a limited time to draw, the stand-by mode usually doesn’t need to be disabled.

It’s relevant to disable the stand-by mode only in video-or demonstration modes, when the player doesn’t need to interact at all for a certain time. It’s more important, how the game reacts on the stand-by mode. It’s the best solution if a game automatically switches to the pause-menu on a stand-by, where the player can easily resume the game.

How to suppress the Stand-By Mode?

You use so called “Wakelocks” to suppress the stand-by mode on a Android Phone. Here I show you a sample implementation using the game-engine e3roid. It’s very important to release the Wakelock before exiting the game.


You need to request the nessesary permision:

<uses-permission android:name="android.permission.WAKE_LOCK" />

Main Class:

public class StoneSetter extends E3Activity {
private PowerManager.WakeLock wl;
public E3Scene onLoadScene() {
   PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
   wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "SomeTag");
public boolean onKeyDown(E3Scene in_scene, int keyCode, KeyEvent event) {
if((keyCode == KeyEvent.KEYCODE_MENU || keyCode == KeyEvent.KEYCODE_BACK)){
   return true;
   return false;
public void exitGame(){

Game Development Considerations

If you want to develop a game, you have to think first about the genre to develop the game for. Should it be a puzzle game / board game or an action game? After answering this question you have a lot of follow up questions to answer.

If you choose an action game (Jump&run) you have to take care of a lot more things than in a turn based game. You always have to take care that your programming is really performant, to achieve high frame rates. In a turn-based-game it’s less important as the user usually doesn’t notice if a calculation takes a little longer. A good overview on this topic is documented in this article, which is unfortunately only available in German language: Real Time vs Turn Based Games.

My first Android-Game-Project was such an Action Game. But the performance itself wasn’t the biggest problem for me (after I found some good 2d Game Engines). The biggest problem has been the level design, which take a large amount of time. That is why I postponed this project. After the start phase the level design took up about 80% of the development time.

Sample of my first Project(Graphics mainly from – a really good source for grafics and more)

Continue reading

e3roid example: Score handling – displaying the score

Something nearly every classic game needs, is the display of a score. A simple text doesn’t look “game like” – so a normal “textsprite” wasn’t my choice for displaying the score.

In this article you find my implementation a score-display class for e3roid based on animated sprites. I could also have used “TiledSprites”, but I still have the vision of letting the numbers change with animation – but I haven’t started implementing this yet.

To use the source code below you first need a e3roid body. Best is to extend the code of the Tutorial “Handle touch events” on the e3roid-page. If you follow the instructions below, the course will be increased with each touch-action.

Here you see how a sample coding could look like:

Continue reading