Moving a Ball on iPhone
- by Chandan Shetty SP
I am using below formula to move the ball circular, where accelX and accelY are the values from accelerometer, it is working fine.
But the problem in this code is mRadius(I fixed its value to 50), i need to change mRadius according to accelerometer values and also i need bouncing effect when it touches other circles please send your answers ASAP... I am waiting.
float degrees = -atan2(accelX, accelY) * 180 / 3.14159;
int x = cCentrePoint.x + mRadius * cos(degreesToRadians(degrees));
int y = cCentrePoint.y + mRadius * sin(degreesToRadians(degrees));
Here is the snap of the game i want to develop.
http://iphront.com/wp-content/uploads/2009/12/bdece528ea334033.jpg.jpg