I implemented Andengine analog onscreencontrol in a game. I am calculating the angle of the knob on onscreencontrol and giving it to the physics body. The values are not smooth.
Controller = new AnalogOnScreenControl(width/6, height/6, camera, resourcesManager.Controller_Base, resourcesManager.Controller_knob , 0.1f, vbom, new IAnalogOnScreenControlListener() {
public void onControlChange(final BaseOnScreenControl pBaseOnScreenControl, final float pValueX, final float pValueY) {
System.out.println("the values are " + pValueX + " & "+ pValueY);
float xvalue = pValueX/10;
float yvalue = pValueY/10;
if(pValueX == x1)
{
}
else {
// linear velocity
planeBody.setLinearVelocity(new Vector2(pValueX * 50, pValueY * 50));
planeBody.setFixedRotation(true);
planeBody.setTransform(planeBody.getWorldCenter(),-(float)Math.atan2(pValueX, pValueY) );
planeBody.setAngularVelocity(0);
}
}
public void onControlClick(final AnalogOnScreenControl pAnalogOnScreenControl) {
/* Nothing. */
}
});
Please suggest me something to make the rotation of the physics body smooth. So that it should provide values very smoothly some what kind of like tolerance.