[英]Cocos2d - how to scale two CCNodes with respect to each other
I have two CCNodes in Cocos2d that I want to dynamically scale in sync with each other. 我在Cocos2d中有两个CCNode,我想动态地相互同步缩放。 Both CCNodes are background nodes.
两个CCNode都是后台节点。 Visually one CCNode, NodeA, is above the other CCNode, NodeB in the y direction.
视觉上,一个CCNode,NodeA,在y方向上位于另一个CCNode,NodeB之上。 But when I scale both nodes at the same time as in the code below:
但是,当我在下面的代码中同时缩放两个节点时:
Edit #1 - 编辑#1 -
Node B is part of a CCLayer, HUDLayer. 节点B是CCLayer,HUDLayer的一部分。 The HUDLayer doesn't scale but NodeB in the HUDLayer does scale.
HUDLayer不会扩展,但HUDLayer中的NodeB会扩展。 So the code looks like
所以代码看起来像
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?
End Edit #1 结束编辑#1
Edit #2 编辑#2
The contentSize of CCNode is (0,0). How do I set the contentSize of CCNode manually?
End Edit #2 结束编辑#2
Edit #3 编辑#3
I found this post where one of the answers talks about setting a CCNode's relativeToAnchorPoint property to YES. 我找到了这篇文章 ,其中一个答案谈到将CCNode的relativeToAnchorPoint属性设置为YES。 I can't find how to do this on Google.
我在谷歌上找不到如何做到这一点。 Does anyone know how to set relativeToAnchorPoint?
有谁知道如何设置relativeToAnchorPoint?
End Edit #3 结束编辑#3
NodeA drops below NodeB in the y direction. NodeA在y方向下降到NodeB下方。 So this brings up a few questions:
所以这提出了一些问题:
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?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.