绕锚点精灵 [英] rotate a sprite around an anchor point
本文介绍了绕锚点精灵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个精灵:
ombreoeuf1 = [CCSprite spriteWithFile:@"mangeurcentremieu3_03.png" ];
ombreoeuf1.position = ccp(240,160);
[self addChild:ombreoeuf1];
和我想不断旋转它周围的锚点。我该怎么办呢?
And I would like to rotate it constantly around an anchor point. How can I do it?
推荐答案
您可以先通过设置属性设置锚点 anchorPoint
,例如:
You can first set anchor point by setting the property anchorPoint
, for example:
[ombreoeuf1 setAnchorPoint:ccp(0,0)]
通过设置另一个属性,然后设置旋转(度)旋转
:
[ombreoeuf1 setRotation:90]
anchorPoint
和旋转
是的的CCNode类,这是CCSprite的父。
anchorPoint
and rotation
are both properties of CCNode class, which is the parent of CCSprite.
更新
根据您的意见,似乎你想要的是一个旋转的精灵,从来没有停止?这里是一个让精灵旋转每0.1秒10度的例子:
According to your comments, it seems that what you want is a rotating sprite which never stops? Here is an example which let the sprite rotate 10 degrees per 0.1 seconds:
[sprite runAction:[CCRepeatForever actionWithAction:[CCRotateBy actionWithDuration:0.1 angle:10]]];
这篇关于绕锚点精灵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文