1

平台 -> cocos2D,iOS

第 1 步:使用ImageFormat="RGBA8888"FileName.pvr.ccz(TexturePacker) 加载动画 在 x-code Instruments 10.0 MB 中显示内存使用情况。

第 1 步:使用ImageFormat="RGBA4444"FileName.pvr.ccz(TexturePacker) 加载动画 在 x-code Instruments 10.0 MB 中显示内存使用情况。

问题->为什么在使用较低的ImageFormat = "RGBA4444"而不是较高的ImageFormat = "RGBA8888"时,它在内存使用方面没有任何差异?

TexturePacker 文件大小 = 2047 * 1348

4

2 回答 2

0

默认纹理格式为 RGBA8888,因此如果您有 RGBA4444 纹理,则需要在加载纹理之前更改格式(并且可能在之后将其更改回来)。

为新创建的纹理更改纹理格式的方法是 CCTexture2D 的一个类方法

 + (void) setDefaultAlphaPixelFormat:(CCTexture2DPixelFormat)format;
于 2014-04-01T12:33:28.027 回答
0

我发现此错误导致两种格式的内存大小相同:- http://www.cocos2d-iphone.org/forum/topic/31092

在 CCTexturePVR.m ->

            // Not word aligned ?
            if( mod != 0 ) {

                NSUInteger neededBytes = (4 - mod ) / (bpp/8);
                printf("\n");
                NSLog(@"cocos2d: WARNING. Current texture size=(%tu,%tu). Convert it to size=(%tu,%tu) in order to save memory", _width, _height, _width + neededBytes, _height );
                NSLog(@"cocos2d: WARNING: File: %@", [path lastPathComponent] );
                NSLog(@"cocos2d: WARNING: For further info visit: http://www.cocos2d-iphone.org/forum/topic/31092");
                printf("\n");
            }

它的 cocos2d 或 iOS 错误,可以通过调整 pvr.ccz 大小来处理 大小尺寸应该可以被 4 整除,但不能被 2 的幂。它将解决错误并获得两种格式的预期内存差异

于 2014-04-02T08:42:30.637 回答