public void onControlChange(final BaseOnScreenControl pBaseOnScreenControl, final float pValueX, final float pValueY) {
final Body carBody = CityRacerActivity.this.mCarBody;
final Vector2 velocity = Vector2Pool.obtain(pValueX * 5, pValueY * 5);
carBody.setLinearVelocity(velocity);
Vector2Pool.recycle(velocity);
final float rotationInRad = (float)Math.atan2(-pValueX, pValueY);
carBody.setTransform(carBody.getWorldCenter(), rotationInRad);
CityRacerActivity.this.mCar.setRotation(MathUtils.radToDeg(rotationInRad));
}
So this works partially.
OnControlChange moves the sprite in the correct direction but when I let go to the controls it seems to move the vehicle facing upwards everytime.
I’m on android using andengine.
My code is based off of the racergameactivity example but this error seems to already exist withen the example itself.
This works like I wanted but I’m not sure if this is the way I should handle it.