zoukankan      html  css  js  c++  java
  • cocos2dx:利用CCSpriteBatchNode优化渲染效率

    生成精灵同城的方法是CCSprite::spriteWith**,用这种方法每生成一个精灵就进行渲染一次,如果需要渲染的精灵特别多,那就会影响效率。

    CCSpriteBatchNode的原理是一次性的把需要渲染的精灵全部渲染,然后再生成精灵,在精灵特别多的时候优化效果会很明显。

    1 CCSpriteBatchNode* batchNode = CCSpriteBatchNode::batchNodeWithFile("PackUnLock.png", 2000);
    2     batchNode->setPosition(CCPointZero);
    3     goodsPanel->addChild(batchNode);
    4     for (int i=0; i<2000; i++) {
    5         //CCSprite* cellBk = CCSprite::spriteWithFile("PackUnLock.png");
    6         CCSprite* cellBk = CCSprite::spriteWithTexture(batchNode->getTexture());
    7         cellBk->setPosition(goodPos[i].pos);
    8         goodsPanel->addChild(cellBk);
    9     }
  • 相关阅读:
    PHP正则表达式概念
    PHP函数
    PHP基础知识总
    PHP运算符知识点
    PHP基础知识1
    学习JavaScript时的三部分
    怎么面向对象编程呢?
    封装、继承、多态
    JS面向对象
    作业day01
  • 原文地址:https://www.cnblogs.com/arthas/p/2790341.html
Copyright © 2011-2022 走看看