English 中文(简体)
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 es 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...

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签