在Cocos2d(Android,JAVA)中,我使用CCRotateBy来旋转一个CCNode,其中包含多个子节点。我想使用中心图 block 的中心作为旋转点,所以我想我应该使用 anchor 。
但是,无论我为 anchor 赋予什么值,图 block 都会围绕屏幕左下角旋转。怎么会?
(图 block 是 CCNode,收集在两个列表中,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(内容右上角)范围内的因子
您将 anchor 设置为距节点 700,700 太远
关于java - RotateBy Anchorpoint 不影响旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28519484/