Posts

Showing posts from January, 2012

Android Game Programming : Game Loop and Animation.

Image
In this tutorial we are going to see the "Game Loop" concept and a little about animations techniques. The game loop is the repetition of too main activities: Physics update; this is the game data update as for example the x and y position coordinates for a little character (Sprites positions, Score base in time, ...) Drawing; this is about drawing the picture you see in the screen. When this method is called repeatedly it gives you the perception of a movie or of an animation. We are going to execute the game loop in a separated thread. In one thread we call the updates and drawings and in the main thread we handle the events like we use to do in a normal application. The code below shows this implementation: package com.edu4java.android.killthemall; import android.graphics.Canvas ; public class GameLoopThread extends Thread {        private GameView view ;        private boolean running = false ;               public GameLoopTh