Reputation: 5629
What is the best way to create instance of CCSprite from downloaded image file?
I would like to implement downloadable additional contents in my Cocos2D game.
The way I used is
If you know more smart way, please let me know.
Upvotes: 1
Views: 1174
Reputation: 2683
If you have a UIImage named img;
sprite can be created by
CCSprite *s = [CCSprite spriteWithCGImage:img.CGImage key:@"image"];
Upvotes: 2
Reputation: 64477
Have a look at my tutorial How to Download (only) Modified Files from a Webserver. I used this to build a Cocos2D Webcam Viewer and contains example code for downloading files via NSData, saving it to the documents directory and creating a texture/sprite from the downloaded image file.
Upvotes: 1