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

丶灬走出姿态 提交于 2019-12-08 07:06:35

问题


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.


回答1:


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.

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




回答2:


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

sharedFileUtils.searchMode = CCFileUtilsSearchModeSuffix


来源:https://stackoverflow.com/questions/29853468/cocos2d-swift-v3-x-sprite-builder-in-ipad-iphone-sd-images-are-used-ipad-suf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!