【问题标题】:-[CCFileUtils fullPathForFilename:resolutionType:] : cocos2d: Warning: File not found:-[CCFileUtils fullPathForFilename:resolutionType:] : cocos2d: 警告:找不到文件:
【发布时间】:2014-06-26 06:16:58
【问题描述】:

-[CCFileUtils fullPathForFilename:resolutionType:] : cocos2d: Warning: File not found: 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 文件。

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

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

【问题讨论】:

  • 这些菜单项初始化器不会在纹理图集中查找精灵帧。要使用精灵帧,请使用将现有精灵作为输入的菜单项初始化程序,并使用来自图集的精灵帧创建该精灵
  • 我找不到你的意思; CCMenuItemSprite?
  • 我试过 CCSprite *test = [CCSprite spriteWithSpriteFrameName:@"play.png"]; CCMenuItemSprite *play = [CCMenuItemSprite itemWithNormalSprite:test selectedSprite:test target:self selector:@selector(actionGame:)];但错误说:原因:'孩子已经添加。无法再次添加'
  • 我认为你不能对普通和选定的精灵使用相同的精灵
  • 由于某种原因,它甚至无法从精灵表中找到图像? -[CCFileUtils fullPathForFilename:resolutionType:] : cocos2d: 警告:找不到文件:(即使我更改了选择)

标签: ios objective-c menu cocos2d-iphone texturepacker


【解决方案1】:

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

如果它发生在第一个之后:

检查你是否使用过;

[[CCTextureCache sharedTextureCache] removeUnusedTextures];

在初始化之后的某个地方。我的项目也出现了同样的问题,我认为上面的代码没有像我预期的那样工作。

【讨论】:

    猜你喜欢
    • 2015-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多