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.
- Select Copy files in the coming File Operation dialog.
- 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.
- Create SurfaceView for our game
- Implement background thread for our game
- Link SurfaceView and Background Thread work together
- Flickering problems due to double buffer of SurfaceView
- Create transparent foreground SurfaceView
- Introduce Sprite
- Sprite auto-run
- Implement onTouchEvent() to handle user touch on SurfaceView
- React device movement/orientation using accelerometer
- Gestures detection and canvas scale, translate and rotate.
Thank you! This has been a fantastic intro-level walkthrough. Now I can build my tower defense game :)
ReplyDeleteThanks for sharing your knowledge. This is just what i was looking for, an introduction to Game Development for Android. Thank you very much.
ReplyDeleteI 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.
ReplyDeleteIs this due to the overloading on main thread? Can you suggest some fix that could solve the problem?