Z order

一、看到cocos2d中有一段對Z order的介紹/**
     * Sets the Z order which stands for the drawing order, and reorder this node in its parent's children array.
     *
     * The Z order of node is relative to its "brothers": children of the same parent.
     * It's nothing to do with OpenGL's z vertex. This one only affects the draw order of nodes in cocos2d.
     * The larger number it is, the later this node will be drawn in each message loop.
     * Please refer to setVertexZ(float) for the difference.
     *
     * @param nZOrder   Z order of this node.

     */

  Z order用於表示node節點被描繪的順序和記錄它在父節點中的子節點數組中的位置。

node節點的Z order只是和當前的父節點的所有子節點的進行比較和起作用,具有局部性。

Z order跟OperGL的頂點無關,它只是cocos2d的節點的畫圖特性;

Z order越大,則表示節點在消息循環中被描繪的順序越靠後;

可以使用setVertexZ對節點的Z order進行設置,node的nZOrder代表了node的Z order值;


二、setZOrder和_setZOrder之間的區別:_setZOrder僅僅是設置m_nZOrder的成員變量值;setZOrder先是首先設置m_nZOrder的值,然後記錄該節點在父節點的子節點數組終端的位置---m_uOrderOfArrival成員變量;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章