ios - -[CCFileUtils fullPathForFilename:resolutionType:]:cocos2d:警告:找不到文件:

标签 ios objective-c menu cocos2d-iphone texturepacker

-[CCFileUtils fullPathForFilename:resolutionType:]:cocos2d:警告:找不到文件:play.png

Cocos2d游戏...。非常简单就开始了。

这是整个类,找不到“play.png”和“sound.png”。它们都位于“buttons.plist”(纹理包装器文档)中,并包含在“构建阶段”中。

类:

- (id) init {

    if ((self = [super init])) 
    {
    //[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"looped.mp3" loop:YES];
        [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"buttons.plist"];

        CGSize winSize = [CCDirector sharedDirector].winSize;

        CCSprite* background;
        if( winSize.width == 568 || winSize.height == 568 )
            background = [CCSprite spriteWithFile: @"title_bg-5x.png"];
        else
            background = [CCSprite spriteWithFile: @"title_bg.png"];

        [background setPosition: ccp(winSize.width/2, winSize.height/2)];
        [self addChild: background];

        CCMenuItemImage *play = [CCMenuItemImage itemWithNormalImage:@"play.png" selectedImage:@"play.png"
                                                                   target:self selector:@selector(actionGame:)];


        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            play.position =  ccp(winSize.width/2,winSize.height/2);
        }
        else
        {
            play.position =  ccp(winSize.width/2,winSize.height/2);
        }

        CCMenuItemImage *sound = [CCMenuItemImage itemWithNormalImage:@"sound.png"
                                               selectedImage: @"sound.png"
                                                      target: self
                                                    selector:@selector(actionSound:)];
        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            sound.position=ccp(winSize.width/2,winSize.height/2);
        }
        else
        {
            sound.position=ccp(winSize.width/2,winSize.height/2);
        }


        CCMenu *menu = [CCMenu menuWithItems:play, menu, nil];
        [self addChild:menu z:4];

    }


    return self;
}

航海家:

Build Phases也具有所有.plist文件和.png文件。

有任何想法为什么我会收到此错误/为什么按钮不显示?这仅仅是项目的开始,我从来没有遇到过这个问题。

感谢您能为我提供的任何帮助。

最佳答案

它是在第一次初始化还是之后初始化?

如果发生在第一个之后:

检查您是否使用过;

[[CCTextureCache sharedTextureCache] removeUnusedTextures];

初始化后的某个地方。我的项目也发生了同样的问题,我认为上面的代码无法按我预期的那样工作。

关于ios - -[CCFileUtils fullPathForFilename:resolutionType:]:cocos2d:警告:找不到文件:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24423603/

相关文章:

html - 如何获得完全响应的圆形菜单(包括悬停+链接功能)?

html - 将鼠标悬停在下拉列表中的子 <a> 上时,请在父 <a> 上突出显示

visual-studio - 如何嵌套 VS 扩展的工具菜单按钮?

iphone - 按钮设置突出显示不起作用

ios - NSPredicate如何过滤对象字段

ios - 在 Swift 中获取子目录中资源的所有 URL

iphone - iOS5 中 UIPickerView 选择 RowInComponent 的不同奇怪行为

Objective-C 'RootViewController' 可能无法响应 xCode 中的 '-parseXMLFileAtURL:' 错误

iPhone 地址簿 - 始终从默认组中提取

objective-c - 哪些问题可能导致将 nib 文件的所有者设置为 nil?