Cocos2d-Swift v3.x Sprite Builder : 在 iPad iPhone sd 图像被使用.-ipad 后缀被忽略后缀、图像、Sprite、Cocos2d

2023-09-06 10:16:15 作者:扑倒李太白

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
在cocos2dx 中添加自定义 shaders 改变 HSL 色调,饱和度, 亮度

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.

解决方案

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.