cocos2d--利用Anchor Point巧妙旋转

来源:互联网 发布:杨振宁 院士 知乎 编辑:程序博客网 时间:2024/06/10 23:56

入门篇参见http://www.qcmat.com/understanding-anchorpoint-in-cocos2d/

在游戏中,通常情况下我们设置anchor point为(0.5,0.5),这样最大的好处是旋转时中心在图片中心。

然而有时我们需要精灵能够绕着某一点旋转,这时利用anchor point能够轻易做到。

假设精灵位置为(0,0),anchor point为(2,2),精灵大小(width,height),则在执行rotate action时,精灵图片中心会在(1.5*width,1.5*height处),围绕

(0,0)进行旋转。

原创粉丝点击