我正试着从地图册上画一个精灵。我用Zwoptex创建了地图集和plist文件。将这两个文件放入“共享”文件夹中。
在代码中,我创建了新的GameScene类
试着装上..。
//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: java.io.FileNotFoundException: 1.png 04-28 12:45:32.642: java.io.FileNotFoundException: Screen_01_0029_BG_01-0.png 04-28 12:45:32.622: ERROR/CCSpriteFrameCache(1147):不支持的Zwoptex plist文件格式。
屏幕_01_0029_BG_01-0.png指的是1级地图集中的一个帧。
思想?
ER
发布于 2012-06-30 13:59:34
首先,您需要在"CCSprite.sprite“构造函数中将"true”语句作为第二个参数传递。通过这种方式,您可以指示cocos2d,您打算使用作为资源plist文件的一部分的sprite映像,而不是作为项目的\res文件夹中的独立映像。如果这没有帮助,您可能需要从\libs目录中删除cocos2d JAR文件,并从github下载源代码。如果您这样做,请注释掉CCMenuItemSpite.java类中的“绘制”方法,因为它会生成双图像。类的默认行为工作得很好。您还可能需要删除一些“@重写”指令,特别是如果您有Eclipse的最新版本,就像我在获得源文件以正确构建并链接到您的项目之前所做的那样。我希望这能帮点忙..。
https://stackoverflow.com/questions/5816803
复制相似问题