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);
}
"center"변수를 자식으로 추가해야합니까? – Gargo
물론 생성했지만 노드로 추가하지 않은 노드는 메모리에서 해제됩니다. 그리고 그것과 함께 모든 아이들. – LearnCocos2D
나는 그것을 시험해 보았다. 스프라이트를 단순히 회전 시키려면 완벽하게 작동합니다. 그러나 일부 Sprite는 절대 위치를 사용하고 일부 Sprite는 상대 위치를 사용하기 때문에 충돌 감지에 많은 문제가 있습니다. – Gargo