1

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.

Sandeep R
  • 2,284
  • 3
  • 25
  • 51

1 Answers1

0

Use Modifiers: In this case you are looking for the RotationModifier.

Izu
  • 235
  • 1
  • 5
  • I tried rotation modifier . But modifiers only work for sprites , not the physics body. The rotation modifier on the sprite was damn good. But I need it with physics body. – Sandeep R Jun 19 '14 at 10:03