cocos2dx 3.3 setGlobalZOrder对label没有作用

前端之家收集整理的这篇文章主要介绍了cocos2dx 3.3 setGlobalZOrder对label没有作用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. /**
  2. Defines the oder in which the nodes are renderer.
  3. Nodes that have a Global Z Order lower,are renderer first.
  4. In case two or more nodes have the same Global Z Order,the oder is not guaranteed.
  5. The only exception if the Nodes have a Global Z Order == 0. In that case,the Scene Graph order is used.
  6. By default,all nodes have a Global Z Order = 0. That means that by default,the Scene Graph order is used to render the nodes.
  7. Global Z Order is useful when you need to render nodes in an order different than the Scene Graph order.
  8. Limitations: Global Z Order can't be used used by Nodes that have SpriteBatchNode as one of their acenstors.
  9. And if ClippingNode is one of the ancestors,then "global Z order" will be relative to the ClippingNode.
  10.  
  11. @see `setLocalZOrder()`
  12. @see `setVertexZ()`
  13.  
  14. @since v3.0
  15. */
  16. virtual void setGlobalZOrder(float globalZOrder);

今天写代码,准备在最上层加一个label来显示分数,因为之前为了省事儿给好多node设置了GlobalZOrder,可是新添加的这个label一直被上层的node给挡住。

上网查了查才知道:

"Limitations: Global Z Order can't be used used by Nodes that have SpriteBatchNode as one of their censors."

class CC_DLL Label : public SpriteBatchNode,public LabelProtocol

Label是继承了SpriteBatchNode,所以Label设置setGlobalZOrder无效。

也没想到解决办法,还是去掉用的setGlobalZOrder吧。

猜你在找的Cocos2d-x相关文章