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);
    }
  • 相关阅读:
    springboot基本注解
    Mybatis之简单注解
    java再次学习
    在线html编辑器
    分享
    cyberduck的SSH登录
    ie67的冷知识
    css特效
    小程序分享
    css特效博客
  • 原文地址:https://www.cnblogs.com/quansir/p/3160644.html
Copyright © 2011-2022 走看看