![](/img/trans.png)
[英]Cocos2D collision detection of CCSprites on different CCNodes with different position and rotation
[英]Cocos2d - how to scale two CCNodes with respect to each other
我在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
我找到了這篇文章 ,其中一個答案談到將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?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.