java - RotateBy Anchorpoint 不影响旋转

标签 java android cocos2d-android anchorpoint ccrotateby

在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/

相关文章:

android - 无法在 Cocos2d for android 上设置 PixelFormat

android - 如何修复 "Failed to install ' cordova-plugin-console' :Error "

java - 显式调用 SpringBoot 提供的默认 Spring 缓存管理器

java - 使用外部属性的 JBoss 5.1 数据源配置

java indexOf 在应该返回正数时返回 -1

android - 如何将语音识别结果添加到 fragment 中?

Android : Extract article main content. 如何仅提取内容img并删除图标img

java - 为什么我会收到 InvocationTargetException?安卓2D游戏

android - 为android sdk 设置运行cocos2d 示例程序的环境。

java - Spring 休息模板