Game Development Reference
In-Depth Information
OnInitGraphics : This event fires once on graphics initialization and will always fire
before the first call to OnImageUpdate . It receives the width and height of the video
buffer that will be used to create the game bitmap in the Java layer.
OnMessage : This event fires whenever there is a text message from the native layer.
It is mostly used to check what is going on in the native side.
OnStartSound and OnStartMusic : See the next section for details.
Listing 6-6. Native Callbacks from Main Activity
/******************************************************
* Native Events
******************************************************/
@Override
public void OnSysError(final String text) {
mHandler.post(new Runnable() {
public void run() {
MessageBox("System Message", text);
}
});
// Wait for the user to read the box
try {
Thread.sleep(8000);
} catch (InterruptedException e) {
}
// Ouch !
WolfTools.hardExit(-1);
}
@Override
public void OnImageUpdate(int[] pixels, int x, int y, int w, int h) {
mBitmap.setPixels(pixels, 0, w, x, y, w, h);
mHandler.post(new Runnable() {
public void run() {
try {
mView.setImageBitmap(mBitmap);
} catch (Throwable e) {
e.printStackTrace();
}
}
});
}
@Override
public void OnInitGraphics(int w, int h) {
Log.d(TAG, "OnInitGraphics creating Bitmap of " + w + " by "
Search WWH ::




Custom Search