0
我还没有看到有关在指定点周围旋转的简单示例。我想是这样的,但它不工作:Cocos2d。绕另一点旋转点而不需要进行数学计算?
//CCNode *node is declared
//In a function of a subclass of CCSprite
- (void)moveWithCicrlce
{
anchorNode = [CCNode node];
anchorNode.position = ccpSub(self.position, circleCenter);
anchorNode.anchorPoint = circleCenter;
[anchorNode runAction:[CCRotateBy actionWithDuration:1 angle:90]];
[self runAction:[CCRepeatForever actionWithAction:[CCSequence actions:[CCCallFunc actionWithTarget:self selector:@selector(rotate)], [CCDelayTime actionWithDuration:0.1], nil]]];
}
- (void)rotate
{
self.position = ccpAdd(anchorNode.position, anchorNode.anchorPoint);
}
我必须添加“中心”变量作为孩子吗? – Gargo
当然,您创建但不作为子项添加的任何节点都将从内存中释放。和它的所有孩子一起。 – LearnCocos2D
我试过了。如果你想简单地旋转精灵,它是完美的。但碰撞检测有很多问题,因为有些精灵使用绝对位置,有些使用相对位置。 – Gargo