1

Code:

var bg = CCSprite(imageNamed:"Background.png") 

Images used in Resource:

Background-hd.png
Background-ipad.png
Background-ipadhd.png
Background-iphone5hd.png
Background.png

In all device Background.png(320x480) used, other images are ignored. How to fix this ?

Retina display is not enabled...How to enable retina display in v3 ?

Here is working sample code with this problem.

2 Answers 2

1
+50

I'm not really advanced user of SpriteBuilder but have some concerns about your issue.

As you are using Sprite Builder for starting the project, it configures your CCFileUtils to distinguish different devices' resources by looking at folders, not prefixes. In your app delegate you can see this line:

[CCBReader configureCCFileUtils];

going into this method you can see that search mode for file utils is set to CCFileUtilsSearchModeDirectory

sharedFileUtils.searchMode = CCFileUtilsSearchModeDirectory;

So you need to use Publish folders and copy your Background image to each of them with the same name (Background.png), but with different resolution for each device. enter image description here

You don't need to use image suffixes in SpriteBuilder at all.

4
  • not worked, even retina display is not enabled. Also there is no resource folder for iphone5, Is there any simple way to switch it to old way like -hd,-ipad ? any simple solution ?
    – Guru
    Apr 27, 2015 at 14:50
  • thanks a lot for hints about CCFileUtilsSearchModeDirectory. I just replaced it with CCFileUtilsSearchModeSuffix and everything is working fine now.
    – Guru
    Apr 27, 2015 at 17:20
  • Great! I'm glad it helped. I had experience in cocos2d some time ago but I'm not experienced SpriteBuilder user, so sorry for such a short answer. Strange that it didn't work just by copying resources to Published-iOS folders, I have it working fine as expected. Here's a link to your sample project corrected with resources named Background.png and sorted to a corresponding devices' folders dropbox.com/s/tiy3tmgxtdyckf2/EntryMain.zip?dl=0 Apr 27, 2015 at 20:09
  • 1
    As for iphone 5 you need to name the folder as "resources-iphone5hd" just like another ones, and hope it works :) It seems that SpriteBuilder is not really updated to support iPhone 5, 6, 6+ and your way to use naming suffixes is a great idea. (cocos2d updates are much more frequent) Apr 27, 2015 at 20:14
1

Finally Updated Cocos2d and now -hd,-ipad files are used. Just updated one line

sharedFileUtils.searchMode = CCFileUtilsSearchModeSuffix

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.