Reputation: 2921
I have two CCNodes in Cocos2d that I want to dynamically scale in sync with each other. Both CCNodes are background nodes. Visually one CCNode, NodeA, is above the other CCNode, NodeB in the y direction. But when I scale both nodes at the same time as in the code below:
Edit #1 -
Node B is part of a CCLayer, HUDLayer. The HUDLayer doesn't scale but NodeB in the HUDLayer does scale. 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
Edit #2
The contentSize of CCNode is (0,0). How do I set the contentSize of CCNode manually?
End Edit #2
Edit #3
I found this post where one of the answers talks about setting a CCNode's relativeToAnchorPoint property to YES. I can't find how to do this on Google. Does anyone know how to set relativeToAnchorPoint?
End Edit #3
NodeA drops below NodeB in the y direction. 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?
Upvotes: 1
Views: 547
Reputation: 64477
Upvotes: 3