Online Test Banks
Score higher
See Online Test Banks
eLearning
Learning anything is easy
Browse Online Courses
Mobile Apps
Learning on the go
Explore Mobile Apps
Dummies Store
Shop for books and more
Start Shopping

Cheat Sheet

Android Game Programming For Dummies

Developing games for Android is a complex task. But it's possible if you approach the project step by step. These guidelines will help you make short work of big projects.

Android Game Development Help

Developing an Android game is a complex process, but there's plenty of experience to guide you. Online and personal resources can make the process a journey of discovery, not dead ends:

  • Stuck with a technical question about how to accomplish a particular task or deal with a bug? Try posting the question at StackOverflow.com or on the Android Developer Google Group.

  • Samples of games and other apps are included in the Android SDK in the directory where you installed the SDK (/android/samples/<sdk-version>).

  • Test on as many devices as you can! The emulator is a decent tool, but don't rely on it to provide the same game experience as a hardware device.

  • Get feedback from friends, families, and other beta testers. They can be your most valuable resources in game development.

Android Game Design Preparation

Before you begin developing an Android game, it pays to be prepared. You need to answer the following questions before you begin programming your game:

  • Who is your target audience?

  • Which hardware/software versions are you targeting?

  • Do you plan to monetize your game? If so, how?

  • What genre is your game?

  • Who is your competition?

  • Is your game single or multiplayer? Is it social?

  • How will people control and interact with your game?

  • Are you targeting other cultures/languages?

  • Are you targeting players with special needs?

  • Where will you get the art and sound resources?

Common Android Game Development Tasks

In the process of developing Android games, you'll perform a few common tasks over and over. If these tasks aren't already automatic for you, keep them handy.

Fix an app in portrait or landscape (in manifest file):

<activity
   android:label="@string/app_name"
   android:name=".MyActivity" 
   android:screenOrientation="portrait"                            
   android:configChanges="orientation|keyboardHidden"              
/>

Disable screen timeout:

public class MyActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MyView myView = new MyView(this);
        myView.setKeepScreenOn(true);                                   
        setContentView(myView);
    }
}

Load an image:

private Bitmap myImage;
public myView(Context context) {
       super(context);
       myImage=
BitmapFactory.decodeResource(getResources(),R.drawable.my_image);
}

Draw an image:

@Override
protected void onDraw(Canvas canvas) {
   canvas.drawBitmap(myImage, 0, 0, null);
}

Load a sound:

Soundpool sounds = new SoundPool(5,AudioManager.STREAM_MUSIC, 0);
int mySound = sounds.load(myContext, R.raw.my_sound, 1);

Play a sound:

AudioManager am = (AudioManager)
    myContext.getSystemService(Context.AUDIO_SERVICE);
float volume = (float) 
    audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
sounds.play(mySound, volume, volume, 1, 0, 1);
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.