I have the following code:
Sprite sPlayer = new Sprite(800 / 2, 480 / 2,
playerTextureRegion,
engine.getVertexBufferObjectManager()){
@Override
public boolean onAreaTouched(final TouchEvent tEvent, final float X,
final float Y)
{
if ( tEvent.isActionDown() )
// Some code
return true;
};
};
gameScene.registerTouchArea(sPlayer);
gameScene.setTouchAreaBindingOnActionDownEnabled(true);
gameScene.attachChild(sPlayer);
- When I run it, it gives me error and the app closes
- I see most people using
gameScene.setTouchBindingEnabled(True)
instead ofgameScene.setTouchAreaBindingOnActionDownEnabled(true);
but Eclipse doesn't recognize this one and I can't import any package for it. What exactly am I doing wrong?
Thanks in advance for your answers.
According to your comment, you need to use the function
runOnUiThread
or, you can use the function
toastOnUiThread
:where
YourActivity
is your activity in the game(just pass a reference to it)