Hi.
First of all, thank you for putting together these awesome tutorials. I just got my first droid yesterday, and I'm already rendering in OGL (took me way longer to get my first app up on win32 oh so many years ago.) This has been amazing help.
I have a question concerning the sprite remove example...and I think it boils down to me being a C++ dev more than a Java dev and not fully understanding variable scope. I am able to debug through the code below on touch event, and everything is fine until it attempts to remove the sprite. Once I get to the run() function, pScene is out of scope, nulled in the debugger, and the line does nothing. Any idea how I would be able to make this line functional?
Thank you for any assistance you can provide!
Using java Syntax Highlighting
@Override
public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
/* Removing entities can only be done safely on the UpdateThread.
* Doing it while updating/drawing can
* cause an exception with a suddenly missing entity.
* Alternatively, there is a possibility to run the TouchEvents on the UpdateThread by default, by doing:
* engineOptions.getTouchOptions().setRunOnUpdateThread(true);
* when creating the Engine in onLoadEngine(); */
this.runOnUpdateThread(new Runnable() {
@Override
public void run() {
/* Now it is save to remove the entity! */
pScene.detachChild(SpriteRemoveExample.this.mFaceToRemove);
}
});
return false;
}
Parsed in 0.032 seconds, using
GeSHi 1.0.8.4