首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cocos2d iphone-4更新图像资源文件问题

cocos2d iphone-4更新图像资源文件问题
EN

Stack Overflow用户
提问于 2010-08-09 09:03:16
回答 1查看 632关注 0票数 0

这是我的密码。

代码语言:javascript
复制
CCSprite *u = [CCSprite spriteWithFile:@"1_S.png"  rect:CGRectMake(0, 0, 27, 27)];

            u.position = ccp((45.7*i+45.7*(i+1))/2, 467);
            u.tag = i;

            [self addChild:u];

在我的资源文件夹中,我有两个名为

1_S.png

1_S@2x.png

.As我读了医生

https://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/SupportingResolutionIndependence/SupportingResolutionIndependence.html#//apple_ref/doc/uid/TP40007072-CH10

我认为当我在iPhone 4中运行这段代码时,这个映像名为

1_S@2x.png

难道load...but不是.第一张图像是loaded.....why吗??这有版本问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-08-09 10:58:58

OS4代码中有一个缺陷,阻止视网膜显示与cocos2d一起工作。

请参阅有关问题910的此链接:

http://www.cocos2d-iphone.org/wiki/doku.php/release_notes:0_99_4#

代码语言:javascript
复制
Issue #910 is still open.

The workaround is to edit CCTextureCache.m and make the following changes:

//# work around for issue #910
#if 0        // <---- change it to     #if 1
UIImage *image = [UIImage imageNamed:path];
tex = [ [CCTexture2D alloc] initWithImage: image ];
#else
// prevents overloading the autorelease pool
UIImage *image = [ [UIImage alloc] initWithContentsOfFile: fullpath ];
tex = [ [CCTexture2D alloc] initWithImage: image ];
[image release];
#endif //

Again, issue #910 is not a cocos2d bug, but an iOS4 bug. ”@2x” images are not loaded if you use UIImage initWithContentOffile (but the documentation says it should work). So the work around is to use UIImage imageNamed, but it is not enabled by default because it will consume much more memory.
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3438594

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档