Jan 11, 2012

Create a SurfaceView Game step-by-step

In the coming posts, I will TRY to create a basic game, a VERY BASIC GAME: base on SurfaceView implements SurfaceHolder, display something as Sprites, running in backgroud Thread.

New a project MyGame of package com.MyGame, target Android 2.2, API Level 8.

Prepare my character

Creating graph is my weakest. As a example, I decide to copy my character from Android build-in icon.
- Create a /res/drawable folder.

- Open a file explorer and browse to any Android build-in platform drawable folder (ex. /android-sdks/platforms/android-8/data/res/drawable-mdpi/), drag any icon you want to /res/drawable folder under your project.
Drag any icon

- Select Copy files in the coming File Operation dialog.
Copy files

- Rename the drawable to icon_me.png: Click to select the copied icon, click File from Eclipse menu, and Rename...

In the coming posts, I will show more in step-by-step.


  1. Thank you! This has been a fantastic intro-level walkthrough. Now I can build my tower defense game :)

  2. Thanks for sharing your knowledge. This is just what i was looking for, an introduction to Game Development for Android. Thank you very much.

  3. I also developed a simple game and everything was working fine until the game logic started becoming more and more complex. Now the onTouchEvent method of SurfaceView doesn't get called sometimes on some devices.

    Is this due to the overloading on main thread? Can you suggest some fix that could solve the problem?


Infolinks In Text Ads