开发者

how to create bubble shooter game in cocos2d?

开发者 https://www.devze.com 2023-03-30 21:17 出处:网络
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 .

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消