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);
  • 相关阅读:
    webpack学习(一)—— 入门
    AMD 规范
    CommonJS 规范
    webpack 故障处理
    webpack 开发环境
    webpack 插件
    webpack 配置文件
    webpack 使用
    webpack Loader
    webpack常用的插件安装命令
  • 原文地址:https://www.cnblogs.com/ttss/p/4075415.html
Copyright © 2011-2022 走看看