开发者

Unable to load the frame cocos2d for Android

I am trying to draw one sprite from atlas.. I created with Zwoptex the atlas and the plist file. put the two files in the assest folder..

In the code I create new GameScene class

and try to load it..

    //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);                           

In the debugger I am getting these errors:

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: ERROR/CCSpriteFrameCache(1147): Unsupported Zwoptex plist file format.

Screen_01_0029_BG_01-0.png refers to one of the frames in the level1.png atlas...

Thoughts ?

ER


first of all you need to pass the "true" statement as second parameter in the "CCSprite.sprite" constructor. This way you instruct cocos2d that you intent to use a sprite image which is part of a resource plist file instead as a stand alone image in the \res folder of your project. If that won't help you may need to remove the cocos2d JAR file from the \libs directory and download the source code from github. If you do this please comment out the "draw" methods at the CCMenuItemSpite.java class since it produces double images. The default behavior of the class works just fine. You may also need to remove some "@Override" directives, especially if you have a latest version of Eclipse as I do before you get the source files to be properly built and linked with your project. I hope that helps a bit...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜