cocos2dx 3.3 setGlobalZOrder对label没有作用

前端之家收集整理的这篇文章主要介绍了cocos2dx 3.3 setGlobalZOrder对label没有作用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
/**
     Defines the oder in which the nodes are renderer.
     Nodes that have a Global Z Order lower,are renderer first.
     
     In case two or more nodes have the same Global Z Order,the oder is not guaranteed.
     The only exception if the Nodes have a Global Z Order == 0. In that case,the Scene Graph order is used.
     
     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.
     
     Global Z Order is useful when you need to render nodes in an order different than the Scene Graph order.
     
     Limitations: Global Z Order can't be used used by Nodes that have SpriteBatchNode as one of their acenstors.
     And if ClippingNode is one of the ancestors,then "global Z order" will be relative to the ClippingNode.

     @see `setLocalZOrder()`
     @see `setVertexZ()`

     @since v3.0
     */
    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吧。

原文链接:https://www.f2er.com/cocos2dx/345907.html

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