pls any one help me . I am working on a project like bubble shooter,but i have no idea.now i have开发者_Go百科 to find only touch position angle .
float radians=ccpToAngle(ccpSub(tchPoint, ballImg.position));
float degrees = CC_RADIANS_TO_DEGREES( radians);
pls anybody help me ,and give an idea to implement this project.
To find the angle of a vector v (CGPoint v) use atan2 (or atan2f function):
float angle = atan2(v.y, v.x);
The angle will be in radiance, counting from x axes.
You already have the ball position (x,y), touch position (x',y') and the use angle (slope) and voila, you have a vector.
精彩评论