Game Development Reference
In-Depth Information
return;
}
Log.d(TAG, "Start game base dir: " + baseDir + " game=" + game
+ " port:" + portrait);
// Args
final String argv[] = { "wolf3d", game, "basedir", baseDir };
// Load lib
if (!loadLibrary()) {
// this should not happen
return;
}
Natives.setListener(this);
// Audio?
if (mSound)
mAudioMgr = AudioManager.getInstance(this);
new Thread(new Runnable() {
public void run() {
mGameStarted = true;
Natives.WolfMain(argv);
}
}).start();
}
Making Native Callbacks
After the startGame function completes, the following events will cascade from the native layer (see
Listing 6-6):
OnSysError : This event will fire whenever an unrecoverable system error occurs.
The receiver should display the incoming message to the user and quit the
application.
OnImageUpdate : This event will fire every time there is a native video update.
Depending on the frame rate, it may occur around 10 to 20 times per second. The
incoming arguments include:
Android pixels : This is an array of 32-bit integers representing a packed
ARGB pixel.
Frame X and Y coordinates : These are the left and top coordinates of the
video frame.
Frame width and height : These are the width and height of the video frame
respectively.
Search WWH ::




Custom Search