Game Development Reference
In-Depth Information
+ h);
mBitmap = Bitmap.createBitmap(w, h, Config.ARGB_8888);
}
@Override
public void OnMessage(String text) {
System.out.println("** Wolf Message: " + text);
}
/**
* Load JNI library. Native lib lives in ProjectFolder/libs/armeabi/libwolf_jni.so
*/
private boolean loadLibrary() {
Log.d(TAG, "Loading JNI librray from " + WolfTools.WOLF_LIB);
LibraryLoader.load(WolfTools.WOLF_LIB);
// Listen for Doom events
Natives.setListener(this);
return true;
}
void MessageBox(String text) {
WolfTools.MessageBox(this, getString(R.string.app_name), text);
}
void MessageBox(String title, String text) {
WolfTools.MessageBox(this, title, text);
}
Creating Sound and Music Handlers
Good sound and background music are important for any computer game. They provide the realistic
feeling for a great gaming experience. Listing 6-7 shows a section of the main activity that implements
the sound callbacks, which are fired by the native interface class:
OnStartSound : This callback fires whenever the native layer requests a sound to be
played such as firing a gun. The argument is a sound number that maps to a file
name within the project.
OnStartMusic : This callback fires when background music is requested by the
native interface class. Background music files are large and usually play once, as
opposed to sounds that are small and play many times.
The singleton AudioManager handles all sound and music playing using the methods: startSound and
startMusic . For more details, see the section “Sound Handler Classes.”
Listing 6-7. Audio Handlers from the Main Activity
@Override
public void OnStartSound(int idx) {
Search WWH ::




Custom Search