zoukankan      html  css  js  c++  java
  • 关于cocos2d-x面试的问题

    关于高效渲染的问题:

    1、先说下渲染批次:这是游戏引擎中一个比较重要的优化指标,指的是一次渲染凋用。也就是说,渲染的次数越少,游戏的运行效率越高。

    2、CCSpriteBatchNode就是cocos2d-x为了降低渲染批次而建立的一个专门管理精灵的类。

    1、使用CCSprite创建1000个Icon.png到场景中,这样渲染批次就是1000(暂且不考虑其他的精灵)

     
    for(int i = 0;i < 1000;++i){
     int x = arc4random()%960;
     int y = arc4random()%640;
     CCSprite* testIcon = CCSprite::create("Icon.png");
     testIcon->setPosition( ccp(x, y) );
     this->addChild(testIcon);
    }

    2、使用CCSprite创建1000个Icon.png到场景中,但是这里利用了CCSpriteBatchNode批量渲染。这时的渲染批次、FPS如何呢?

     
    CCSpriteBatchNode* batchNode = CCSpriteBatchNode::create("Icon.png", 1000);
    batchNode->setPosition(CCPointZero);
    this->addChild(batchNode);
     
    for(int i = 0;i < 1000;++i){
     int x = arc4random()%960;
     int y = arc4random()%640;
     CCSprite* testIcon = CCSprite::createWithTexture(batchNode->getTexture());
     testIcon->setPosition( ccp(x, y) );
     batchNode->addChild(testIcon);
    }
  • 相关阅读:
    var 和 let 的区别
    js初步认识变量
    弹性布局
    盒模型
    多重样式优先级深入概念
    层叠机制--比较特殊性
    anroid抓包工具tcpdump的用法
    linux find grep组合使用
    Protect Broadcast 保护广播
    android:exported 属性详解
  • 原文地址:https://www.cnblogs.com/quansir/p/3160644.html
Copyright © 2011-2022 走看看