未找到 SpriteBuilder 图像文件未找到、图像文件、SpriteBuilder

2023-09-06 10:31:43 作者:你长得好提神

我在 sprit builder 资源文件夹中添加了一个 .png 图像并已发布.

I have added a .png image in sprit builder resource folder and I have published it.

我在 Published-IOS 下的 Resources 中的 sprite builder 所有文件夹中看到添加的图像.

I see the added image in sprite builder all folder in Resources under Published-IOS.

这里我尝试通过以下方式访问添加的图像.

Here I have tried to access the added image in following ways.

_hero.spriteFrame = [CCSpriteFrame frameWithImageNamed:@"Down.png"];

[_hero setTexture:[CCTexture textureWithFile:@"Game/Down.png"]]

但是这些方法都不起作用.

But none of these methods are working.

它在日志中显示错误.

 -[CCFileUtils fullPathForFilename:contentScale:] : cocos2d: Warning: File not found: Down.png

请帮我解决这个问题.我是使用此 sprit builder 的新手.

Please help me with this to resolve.Am a newbie using this sprit builder.

推荐答案

@"Down.png" 改成 @"Resources/Down.png" 因为你有包括在 SpriteBuilder 中创建的文件夹,用于对 SpriteBuilder 管理的资源文件的任何引用.

Change @"Down.png" to @"Resources/Down.png" because you have to include the folders created in SpriteBuilder for any references to resource files managed by SpriteBuilder.

同样,如果您在名为Levels"的子文件夹中有 some.ccb,则必须使用字符串 @"Levels/some.ccb" 加载它.

Likewise if you had some.ccb in a subfolder named "Levels" you'd have to load it with the string @"Levels/some.ccb".