我在Cocos2d中有两个CCNode,我希望它们彼此同步动态缩放。两个CCNode都是后台节点。视觉上,一个CCNode,NodeA,在y方向上位于另一个CCNode,NodeB之上。但是,当我在下面的代码中同时缩放两个节点时:
编辑#1 -
节点B是CCLayer,HUDLayer的一部分。 HUDLayer不会扩展,但HUDLayer中的NodeB会扩展。所以代码看起来像
NodeA.anchorPoint = ccp(0.5f, 0.0f);
NodeA.scale = scale;
HUDLayer.NodeB.anchorPoint = ccp(0.5f, 0.0f);
HUDLayer.NodeB.scale = scale;
4) Would NodeB being part of a CCLayer effect the Nodes scaled relative positions?
结束编辑#1
编辑#2
The contentSize of CCNode is (0,0). How do I set the contentSize of CCNode manually?
结束编辑#2
编辑#3
我找到了这个post,其中一个答案谈到了将CCNode的relativeToAnchorPoint属性设置为YES。我在谷歌上找不到如何做到这一点。有谁知道如何设置relativeToAnchorPoint?
结束编辑#3
NodeA在y方向下降到NodeB下方。所以这提出了一些问题:
1) Are CCNodes scaled with respect to an anchorPoint?
2) Why is NodeA dropping below NodeB in the y direction?
3) How can two CCNodes be scaled with their relative positions remaining constant?
答案 0 :(得分:3)