RotateBy Anchorpoint不影响旋转

时间:2015-02-14 19:39:20

标签: java android cocos2d-android anchorpoint ccrotateby

在Cocos2d(Android,JAVA)中,我使用CCRotateBy旋转一个CCNode,其中有几个tile作为子项。我想用中心瓷砖的中心作为旋转点,所以我想我会使用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);

1 个答案:

答案 0 :(得分:1)

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

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