Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Android Game Programming By Example
  • Table Of Contents Toc
  • Feedback & Rating feedback
Android Game Programming By Example

Android Game Programming By Example

By : John Horton
4.4 (9)
close
close
Android Game Programming By Example

Android Game Programming By Example

4.4 (9)
By: John Horton

Overview of this book

The book is best suited for existing Android or Java programmers who want to adapt their skills to make exciting Android games. The book is also for determined readers who might have no Android, game programming or even Java experience, but a reasonable understanding of object oriented programming knowledge is assumed.
Table of Contents (13 chapters)
close
close
7
7. Platformer – Guns, Life, Money, and the Enemy
12
Index

The SoundManager class


Throughout the next few chapters, we will be adding sound effects for various events. Sometimes these sounds will be triggered directly in the main PlatformView class, but other times, they will need to be triggered in more remote corners of your code like the InputController class and even within the GameObject class themselves. We will quickly make a simple SoundManager class that can be passed around and used as needed when a beep is required.

Create a new Java class and call it SoundManager. This class has three main parts. In the first part, we simply declare a SoundPool object and a bunch of int variables to hold a reference to each sound effect. Enter the first part of the code, the declaration, and members:

import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.media.AudioManager;
import android.media.SoundPool;
import android.util.Log;

import java.io.IOException;

public class...
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Android Game Programming By Example
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon