Android Development

Author Archive

Creating Sound Effects in Android: Part 1

by Stephen Flockton on Oct.20, 2009, under how to, tutorial

In today’s tutorial I am going to show you my method of creating, managing and using sound effects in Android. In this first part I’ll show you the basic method of encapsulating your sound management code. This method works best when you have a typical application, or simple game all in one thread.Part 2 will show you a more advanced way to manage your sound across multiple classes.

The method I use to play sounds is to use the Sound Pool classes rather then the Media Player classes that the Android dev-guide seems to suggest. While there is nothing wrong with using the Media Player classes for simple applications they did not provide the flexibility I needed.
(continue reading…)

  • Share/Bookmark
21 Comments :, , , more...

Creating Game Menus in Android

by Stephen Flockton on Sep.30, 2009, under how to, tutorial

As requested here is a sample tutorial in how to create a menu system for games in Android. Sorry for the delay but this tutorials take time to code test and write up. Anyway I hope you find it useful.

Before I jump into the code I’m going to take a second to explain my way of coding menus in Android. As we all know Android is built on the concept of activities. If you have been following earlier tutorials you already know how to create activities which can display graphics and deal with player input. But what if you want several different screens, such as options or credits? You could code them all into one activity but you would end up with a bloated and hard to maintain class.
(continue reading…)

  • Share/Bookmark
14 Comments :, , , , more...

2D Sprite Animation in Android Addendum

by Stephen Flockton on Sep.23, 2009, under how to, tutorial

If you read my last tutorial entry here, then you may have come across a problem with the code.

If you load several large bitmaps using the BitmapFactory class to decode the bitmap you application will give you the dreaded force close dialogue box. A quick look in the logcat shows that a bitmap exceeds the virtual machine memory budget.

1
ERROR/AndroidRuntime(750): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget

You may wonder how its possible that a few PNG’s can take up all the 16 mb of memory allocation for an application.
(continue reading…)

  • Share/Bookmark
5 Comments :, , , , , more...

2D Sprite Animation in Android

by Stephen Flockton on Sep.13, 2009, under tutorial

In order to make anything more than very simple games in 2D it’s important to be able to draw animated sprites.

There are several ways to create animated sprites in Android, including using XML based declarations and swapping between multiple bitmaps. But when I came to write my animation code neither of these methods was flexible enough for the kind of animation I needed.

Instead of using these methods I instead used sprite sheets and the functionality provided by the Android bitmap drawing functions to draw each frame of the animation. In a nutshell each frame of animation is set on a single bitmap one after the other. The animation code then plays one frame after the other until the animation is complete. Below is an example of a sprite of a bouncing color changing arrow.
(continue reading…)

  • Share/Bookmark
25 Comments :, , , more...