Guru
Guru

Reputation: 22042

Cocos2d-Swift v3.x Sprite Builder : In iPad iPhone sd images are used. -ipad suffix ignored

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.

Upvotes: 1

Views: 160

Answers (2)

Guru
Guru

Reputation: 22042

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

sharedFileUtils.searchMode = CCFileUtilsSearchModeSuffix

Upvotes: 1

Alexander Tkachenko
Alexander Tkachenko

Reputation: 3281

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.

Upvotes: 1

Related Questions