繁体   English   中英

无法为 Android 加载框架 cocos2d

[英]Unable to load the frame cocos2d for Android

我正在尝试从图集中绘制一个精灵。我用 Zwoptex 创建了图集和 plist 文件。 将这两个文件放在asset文件夹中..

在代码中,我创建了新的 GameScene class

并尝试加载它..

    //Return the ShareFrameCache object.
    CCSpriteFrameCache frameCache = CCSpriteFrameCache.sharedSpriteFrameCache();

    //Loading the list of frames from the list file.
    frameCache.addSpriteFrames("level1.plist");

    //Testing and see if I can load one frame to a sprite
    CCSprite sprite = CCSprite.sprite("Screen_01_0029_BG_01-0.png");

    //Set the position of the frame to the middle of the screen
    sprite.setPosition(CGPoint.ccp(winSize.width/2,winSize.height/2));

  //add the sprite as child so it can be seen on the phone.
  addChild(sprite,0);                           

在调试器中,我收到以下错误:

04-28 12:45:31.662: WARN/System.err(1147): java.io.FileNotFoundException: level1.png 04-28 12:45:32.642: WARN/System.err(1147): java.io.FileNotFoundException :Screen_01_0029_BG_01-0.png 04-28 12:45:32.622:错误/CCSpriteFrameCache(1147):不支持的 Zwoptex plist 文件格式。

screen_01_0029_BG_01-0.png 指的是level1.png图集中的框架之一...

想法?

急诊室

首先,您需要将“true”语句作为“CCSprite.sprite”构造函数中的第二个参数传递。 通过这种方式,您指示 cocos2d 您打算使用作为资源 plist 文件一部分的 sprite 图像,而不是作为项目的 \res 文件夹中的独立图像。 如果这没有帮助,您可能需要从 \libs 目录中删除 cocos2d JAR 文件并从github下载源代码。 如果您这样做,请在 CCMenuItemSpite.java class 中注释掉“绘制”方法,因为它会产生双重图像。 class 的默认行为可以正常工作。 您可能还需要删除一些“@Override”指令,特别是如果您像我一样拥有最新版本的 Eclipse,然后才能正确构建源文件并将其与项目链接。 我希望这会有所帮助...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM