iDevGames Forums
spritesheets and cocos2d - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: spritesheets and cocos2d (/thread-9918.html)



spritesheets and cocos2d - nitin867 - Mar 8, 2012 05:34 AM

how can i use animation and spritesheets in cocos2d programming ?


RE: spritesheets and cocos2d - skyhawk - Mar 8, 2012 11:01 AM

Code:
[[CCspriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"spritesheetfile.plist"]

CCanimation* anim = [CCAnimation animation];
anim.delay = .1;
for(int x = 0; x< 5; x++)
{
   [anim addFrame:[[CCspriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"mything%d.png",x]];
}
CCSprite* sprite = [CCSprite spriteWithFrame:[[CCspriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"mything0.png"]];
[sprite runAction: [CCAnimate actionWithAnimation:anim]];



RE: spritesheets and cocos2d - nitin867 - Mar 9, 2012 01:31 AM

thanks for sharing the information here.. Could you tell me what are the benefits of sprite sheets over openGL ES custom coding in cocos2d ?


RE: spritesheets and cocos2d - skyhawk - Mar 9, 2012 10:40 AM

nope


RE: spritesheets and cocos2d - blot-blaqksheep - Sep 19, 2012 11:47 AM

(Mar 9, 2012 01:31 AM)nitin867 Wrote:  thanks for sharing the information here.. Could you tell me what are the benefits of sprite sheets over openGL ES custom coding in cocos2d ?

For us it was ease of use. We know how to just use sprite sheets so that is what we followed. All we had to do was use something like Texture Packer to make our sprite sheet and then with a couple lines of code we could access it and get all our sprites out for our game.