views:

226

answers:

1

hi, Here is my code...

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];

and in my resource folder i have 2 image files named

1_S.png

and

[email protected]

.As i read the the doc

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

i think when i run this code in iPhone 4 the image named

[email protected]

should load...but it isn't.....the first image is loaded.....why?? IS THIS ANY VERSION PROBLEM???

+1  A: 

there is a bug in the OS4 code preventing retina display from working with cocos2d

See this link regarding issue 910:

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

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.
Bongeh
Hi,Thanks.....but i am not sure how to do this....it tells to editCCTextureCache.m but where.....??can u tell more details??
Rony
in finder in your project folder, go to libs, cocos2d, it'll be in there. Or in xcode, open the cocos2d folder near your classes and hunt it down in there.
Bongeh
i don't mean where the file is....i actually mean where within the file the code have to add....i found the file...
Rony
line 196, around there, in the addImage: method
Bongeh
ok...i think the update version already do this....think better idea is to use update version of cocos for iPhone 4..
Rony