<tfoot id='cCA12'></tfoot>

<small id='cCA12'></small><noframes id='cCA12'>

      <bdo id='cCA12'></bdo><ul id='cCA12'></ul>
  • <i id='cCA12'><tr id='cCA12'><dt id='cCA12'><q id='cCA12'><span id='cCA12'><b id='cCA12'><form id='cCA12'><ins id='cCA12'></ins><ul id='cCA12'></ul><sub id='cCA12'></sub></form><legend id='cCA12'></legend><bdo id='cCA12'><pre id='cCA12'><center id='cCA12'></center></pre></bdo></b><th id='cCA12'></th></span></q></dt></tr></i><div id='cCA12'><tfoot id='cCA12'></tfoot><dl id='cCA12'><fieldset id='cCA12'></fieldset></dl></div>
  • <legend id='cCA12'><style id='cCA12'><dir id='cCA12'><q id='cCA12'></q></dir></style></legend>

      1. 何时使用 CCSpriteBatchNode?

        时间:2024-08-12

        <small id='OKXsG'></small><noframes id='OKXsG'>

          <bdo id='OKXsG'></bdo><ul id='OKXsG'></ul>
          <tfoot id='OKXsG'></tfoot>
        • <legend id='OKXsG'><style id='OKXsG'><dir id='OKXsG'><q id='OKXsG'></q></dir></style></legend>
        • <i id='OKXsG'><tr id='OKXsG'><dt id='OKXsG'><q id='OKXsG'><span id='OKXsG'><b id='OKXsG'><form id='OKXsG'><ins id='OKXsG'></ins><ul id='OKXsG'></ul><sub id='OKXsG'></sub></form><legend id='OKXsG'></legend><bdo id='OKXsG'><pre id='OKXsG'><center id='OKXsG'></center></pre></bdo></b><th id='OKXsG'></th></span></q></dt></tr></i><div id='OKXsG'><tfoot id='OKXsG'></tfoot><dl id='OKXsG'><fieldset id='OKXsG'></fieldset></dl></div>

              <tbody id='OKXsG'></tbody>

                  本文介绍了何时使用 CCSpriteBatchNode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在 Cocos2d 中我将播放动画.动画大约有12帧,每一帧都比较大.其实每一帧的-hd版本还是蛮大的.

                  in Cocos2d I will be playing an animation. The animation has about 12 frames, and each frame is rather big. In fact, the -hd version of each frame is quite huge.

                  无论如何,首先,我通过使用 Zwoptex 将所有 12 帧放入纹理中来创建它.纹理约为 2048x2048.

                  Anyway, first, I created it by putting all 12 frames in a texture using Zwoptex. The texture is about 2048x2048.

                  这样我就可以使用该纹理为 CCSpriteBatchNode 中的 CCSprite 设置动画.

                  This is so I can animate a CCSprite in a CCSpriteBatchNode using that texture.

                  但我似乎收到了 2 级内存警告.

                  But I seem to be getting a level 2 memory warning.

                  现在我想起来了,我不认为 CCSpriteBatchNode 应该用于 one 精灵.我想它只有在你想绘制大量使用相同纹理的精灵时才有用.

                  Now that I think of it, I don't think CCSpriteBatchNode was supposed to be used for one sprite. I guess it was only useful if you wanted to draw lots of sprites that use the same texture.

                  所以我想知道:我应该逐帧动画精灵吗(没有巨大的纹理)?还是可以以不同的方式使用这种巨大的纹理?

                  So I want to know: Should I animate the sprite frame by frame (no huge texture)? Or is it possible to use that huge texture but in a different way?

                  推荐答案

                  CCSpriteBatchNode 是对的.CCSpriteBatchNode 就像一个批处理节点:如果它包含子节点,它将在 1 个单独的 OpenGL 调用中绘制它们(通常称为批量绘制"),在没有 CCSpriteBatchNode(在这种情况下)的情况下,所有批量绘制"将被称为多次作为孩子(精灵)的数量.

                  You are right about CCSpriteBatchNode. CCSpriteBatchNode is like a batch node: if it contains children, it will draw them in 1 single OpenGL call (often known as "batch draw"), in absence of CCSpriteBatchNode (in this case) all the "batch draw" will be called as many time as number of children (sprites).

                  CCSpriteBatchNode 可以引用一个且仅一个纹理(一个图像文件,一个纹理图集),即由 zwoptex 创建的精灵表.只有包含在该纹理中的 CCSprite 才能添加到 CCSpriteBatchNode.添加到 CCSpriteBatchNode 的所有 CCSprite 都在一个 OpenGL ES 绘制调用中绘制.如果 CCSprite 未添加到 CCSpriteBatchNode 中,则每个都需要 OpenGL ES 绘制调用,效率较低.

                  A CCSpriteBatchNode can reference one and only one texture (one image file, one texture atlas) i.e. sprite sheet created by zwoptex. Only the CCSprites that are contained in that texture can be added to the CCSpriteBatchNode. All CCSprites added to a CCSpriteBatchNode are drawn in one OpenGL ES draw call. If the CCSprites are not added to a CCSpriteBatchNode then an OpenGL ES draw call will be needed for each one, which is less efficient.

                  根据您的场景,您不必使用 CCSpriteBatchNode,因为在任何给定时间只渲染一个纹理.

                  According to your scenario, you don't have to use CCSpriteBatchNode since there is only one texture rendered at any given time.

                  所以我想知道:我应该逐帧动画精灵吗(没有巨大的纹理)?还是可以以不同的方式使用这种巨大的纹理?

                  So I want to know: Should I animate the sprite frame by frame (no huge texture)? Or is it possible to use that huge texture but in a different way?

                  没关系.无论如何,您将加载 2048 x 2048 纹理.需要思考的问题是,为什么只有一个 2048 x 2048 纹理会给您 2 级警告?你加载了多少这样的纹理.BTW 2048 x 2048 只支持上面的 iPod3G/iPhone3GS(没问题).

                  It doesn't matter. You will be loading the 2048 x 2048 texture anyways. The issue to ponder is why only one 2048 x 2048 texture is giving you a Level 2 warning? how many such textures are you loading. BTW 2048 x 2048 is only supported on iPod3G/iPhone3GS above (which is fine).

                  如果您正在加载许多纹理(这对我来说似乎是正确的).您需要编写一些逻辑,以便在不需要时卸载纹理.请查看以下方法:

                  In case you are loading many textures (which seems true to me). You need to program some logic where you can unload the texture when they are not necessary. Do look at the following methods:

                  [[CCSpriteFrameCache sharedSpriteFrameCache] removeSpriteFramesFromFile:fileName];
                  [[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
                  [[CCTextureCache sharedTextureCache] removeUnusedTextures];
                  

                  就动画而言,您可以创建 CCAnimation 并使用它,或者(取决于您的场景)您可以使用 setDisplayFrame(CCSpriteFrame frame);

                  As far as animation is concerned you can create CCAnimation and use that or (depending upon your scenario) you can use setDisplayFrame(CCSpriteFrame frame);

                  这篇关于何时使用 CCSpriteBatchNode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:电影播放时如何有菜单-iphone cocos2d 下一篇:混合 C++ 和 Objective-C

                  相关文章

                  <legend id='bdq6b'><style id='bdq6b'><dir id='bdq6b'><q id='bdq6b'></q></dir></style></legend>

                    <small id='bdq6b'></small><noframes id='bdq6b'>

                      <bdo id='bdq6b'></bdo><ul id='bdq6b'></ul>
                    <i id='bdq6b'><tr id='bdq6b'><dt id='bdq6b'><q id='bdq6b'><span id='bdq6b'><b id='bdq6b'><form id='bdq6b'><ins id='bdq6b'></ins><ul id='bdq6b'></ul><sub id='bdq6b'></sub></form><legend id='bdq6b'></legend><bdo id='bdq6b'><pre id='bdq6b'><center id='bdq6b'></center></pre></bdo></b><th id='bdq6b'></th></span></q></dt></tr></i><div id='bdq6b'><tfoot id='bdq6b'></tfoot><dl id='bdq6b'><fieldset id='bdq6b'></fieldset></dl></div>
                    1. <tfoot id='bdq6b'></tfoot>