Rotation angle based on touch move

Posted by Siddharth on Game Development See other posts from Game Development or by Siddharth
Published on 2012-05-29T13:22:36Z Indexed on 2012/05/30 17:02 UTC
Read the original article Hit count: 239

Filed under:

I want to rotate my stick based on the movement of the touch on the screen. From my calculation I did not able to find correct angle in degree. So please provide guidance, my code snippet for that are below.

if (pSceneTouchEvent.isActionMove()) {
    pValueX = pSceneTouchEvent.getX();
    pValueY = CAMERA_HEIGHT - pSceneTouchEvent.getY();
    rotationAngle = (float) Math.atan2(pValueX, pValueY);
    stick.setRotation((float) MathUtils.radToDeg(rotationAngle));

}

© Game Development or respective owner

Related posts about andengine