Using AndEngine, Im trying to move a sprite (ball) with the accelerometer which is supposed to bounce of walls and hit other obstacles.
so far I've found the following two methods.
public void onAccelerometerChanged(final AccelerometerData myAccelerometerData) {
mySprite.setPosition(mySprite.getX() + myAccelerometerData.getX(), mySprite.getY() + myAccelerometerData.getY());
}
This works very smoothly but in a non physics world only. (i.e will not bounce of walls and other obstacles smoothly).
And now using this method which is in the examples provided by AndEngine, the ball has good physics but does not move as smoothly as i would like to.
@Override
public void onAccelerometerChanged(final AccelerometerData pAccelerometerData) {
final Vector2 gravity = Vector2Pool.obtain(pAccelerometerData.getX(), pAccelerometerData.getY());
this.mPhysicsWorld.setGravity(gravity);
Vector2Pool.recycle(gravity);
}
I've also tried multiplying pAccelerometerData with certain values such as 2 and 5, yes it appears more responsive but also makes the ball move a lot faster and difficult to play.
To make my question clear, I would like my game to be as smooth as the balls in Labyrinth or Rebound game are for Android. The balls in them are are more responsive to accelerometer. For instance if you want to stop a moving ball suddenly in Labyrinth, you can but with the following code in andEngine example, it keeps moving for a while as if it is moving in a frictionless world.
Is there anyway I can make it more responsive and smooth like that of the Labyrinth game? https://market.android.com/details?id=se.illusionlabs.labyrinth.lite&hl=en