在Cocos2d(Android,JAVA)中,我使用CCRotateBy旋转其中一个带有多个图块的CCNode作为子代。我想将中心图块的中心用作旋转点,因此我想使用Anchorpoint。

但是,给Anchorpoint赋予什么值都没有关系,图块一直围绕屏幕的左下方旋转。怎么来的?

(图块是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(内容的右上角)范围内的因子

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

10-06 07:23