在Cocos2d(Android,JAVA)中,我使用CCRotateBy将一个带有多个瓦片的CCNode作为子节点进行旋转。我想使用中心瓦片的中心作为旋转点,所以我想使用锚点。
然而,无论我给锚点什么值,瓷砖都会在屏幕左下角旋转。为什么?
(tiles是CCNodes,收集在两个列表中,tilesSelected和secondaryTilesSelected)
// I create one node which holds all the tiles I want to rotate
CCNode tilesToRotate = CCNode.node();
tilesToRotate.addChild(tilesSelected.get(0), 0, 99);
// then, I add the 4 tiles around the previous, center tile
for (int i=0; i < secondaryTilesSelected.size(); i++){
tilesToRotate.addChild(secondaryTilesSelected.get(i), 0, 99);
}
// So, if I change 700,700 hereunder to different values, it doesn't change the centerpoint for Rotation. I guess I don't get it...
addChild(tilesToRotate);
tilesToRotate.setAnchorPoint(CGPoint.make(700,700));
CCAction r90 = CCRotateBy.action(1f, 90f);
tilesToRotate.runAction(r90);
anchorPoint是范围为0,0(左下角)到1,1(内容的右上角)的一个因子
您将锚点设置得离节点太远,位于700700