Skip to main content
Tweeted twitter.com/#!/StackGameDev/status/207520409988505601
Indentation fixed
Source Link
doppelgreener
  • 7.3k
  • 7
  • 44
  • 69

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));

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

}

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));

    }

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));

}
Source Link
Siddharth
  • 2k
  • 5
  • 27
  • 55

Rotation angle based on touch move

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));

    }