0

在 Cocos2d (Android, JAVA) 中,我使用 CCRotateBy 来旋转一个 CCNode,其中包含多个图块作为子节点。我想使用中心瓷砖的中心作为旋转点,所以我想我会使用 Anchorpoint。

但是,我给锚点赋予什么值并不重要,瓷砖会一直围绕我的屏幕左下角旋转。怎么来的?

(瓦片是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);
4

1 回答 1

1

anchorPoint 是 0,0(左下角)到 1,1(内容的右上角)范围内的一个因子

您将锚点设置为离节点太远 700,700

于 2015-02-16T09:29:22.423 回答