Using AndEngine, I am trying to move a sprite (ball) with an accelerometer, which should bounce off the walls and hit other obstacles.
So far, I have found the following two methods.
public void onAccelerometerChanged(final AccelerometerData myAccelerometerData) { mySprite.setPosition(mySprite.getX() + myAccelerometerData.getX(), mySprite.getY() + myAccelerometerData.getY()); }
It works very smoothly, but only in the non-physical world. (i.e. there will be no wall failures and other obstacles smoothly).
And now, using this method, which is contained in the examples provided by AndEngine, the ball has good physics, but does not move as smoothly as we would like.
@Override public void onAccelerometerChanged(final AccelerometerData pAccelerometerData) { final Vector2 gravity = Vector2Pool.obtain(pAccelerometerData.getX(), pAccelerometerData.getY()); this.mPhysicsWorld.setGravity(gravity); Vector2Pool.recycle(gravity); }
I also tried to multiply pAccelerometerData with specific values ββlike 2 and 5, yes, it looks more responsive, but also makes the ball move much faster and hard to play.
To make my question clear, I would like my game to be as smooth as the balls in Labyrinth or Rebound for Android. The balls in them are more sensitive to the accelerometer. For example, if you want to stop a moving ball suddenly in the Labyrinth, you can, but with the following code in the andEngine example, it continues to move for some time, as if it were moving in a world without friction.
In any case, can I make it more responsive and smooth, like playing in a maze? https://market.android.com/details?id=se.illusionlabs.labyrinth.lite&hl=en