Game Development Reference
In-Depth Information
int action = evt.getAction();
if ( action == MotionEvent.ACTION_DOWN) {
Natives.sendNativeKeyEvent(Natives.EV_KEYDOWN
, DoomTools.KEY_DOWNARROW);
}
else if ( action == MotionEvent.ACTION_UP) {
Natives.sendNativeKeyEvent(Natives.EV_KEYUP
, DoomTools.KEY_DOWNARROW);
}
return true;
}
});
// Right
findViewById(R.id.btn_right).setOnTouchListener(
new View.OnTouchListener(){
public boolean onTouch(View v, MotionEvent evt) {
int action = evt.getAction();
if ( action == MotionEvent.ACTION_DOWN) {
Natives.sendNativeKeyEvent(Natives.EV_KEYDOWN
, DoomTools.KEY_RIGHTARROW);
}
else if ( action == MotionEvent.ACTION_UP) {
Natives.sendNativeKeyEvent(Natives.EV_KEYUP
, DoomTools.KEY_RIGHTARROW);
}
return true;
}
});
// More ...
}
Audio Classes
The audio classes are implemented in the package doom.audio and consist of two files: AudioManager and
AudioClip .
AudioManager is a singleton class very similar to the AudioManager class presented in the previous
chapter. Some of the method signatures are different to accommodate the Doom engine:
preloadSounds() : This method preloads the most common Doom sounds to
improve performance. Sounds are encoded in WAVE format.
startSound(String name, int vol) : This method starts the sound given by a
name key at volume vol . The key does not include the file extension, and the
volume ranges from 0 to 100.
startMusic (Context ctx, String key, int loop) : This method starts a
background music file given by key and loops if loop is set to anything other
than 0. An Android context is required by the background AudioClip .
Search WWH ::




Custom Search