zoukankan      html  css  js  c++  java
  • 精灵的属性Zorder的设置

    1.Zorder是CCSprite从父类CCNode那继承来的protected属性:

    class CCNode{

    protected:

      int m_nZOrder;                      ///< z-order value that affects the draw order

    };

    2.影响渲染顺序

    a.精灵默认的Zorder值都是0

    b.Zorder值越大,越贴在屏幕上面,即越后渲染,越不容易被遮挡

    3.与Zorder有关的方法:

      int getZorder();

      void setZorder(int zOrder);

    4.代码实现

      CCSprite * man = CCSprite::create("zorder/man.png");
        man->setScale(0.3f);
        CCSprite * woman = CCSprite::create("zorder/woman.png");
        woman->setScale(0.3f);
        CCSprite * smallThree = CCSprite::create("zorder/another.png");
        smallThree->setScale(0.3f);
    
    
        man->setPosition(ccp(winSize.width / 2 + 30, winSize.height / 2 - 30));
        smallThree->setPosition(ccp(winSize.width / 2, winSize.height / 2));
        woman->setPosition(ccp(winSize.width / 2 - 30, winSize.height / 2 + 30));
    
        addChild(man);
        addChild(woman);
        addChild(smallThree);
    
        /*精灵默认的Zorder都是0*/
        CCLog("%d", man->getZOrder());
        CCLog("%d", woman->getZOrder());
        CCLog("%d", smallThree->getZOrder());
    
        /*Zorder值越大,越贴在屏幕上面,即越后渲染,越不容易被遮挡*/
        man->setZOrder(100);
        smallThree->setZOrder(50);
        woman->setZOrder(0);
  • 相关阅读:
    Web网页配色方案及安全色谱
    JQuery获取元素文档大小、偏移和位置和滚动条位置的方法集合
    IE8的css hack
    jquery 获取元素坐标
    CSS 颜色值
    正则表达式
    JS获取宽度
    常用正则表达式例子
    HTML转义字符
    myeclipse 10.0 含破解补丁/注册机
  • 原文地址:https://www.cnblogs.com/ttss/p/4075415.html
Copyright © 2011-2022 走看看