iDevGames Forums

Full Version: spritesheets and cocos2d
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
how can i use animation and spritesheets in cocos2d programming ?
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]];
thanks for sharing the information here.. Could you tell me what are the benefits of sprite sheets over openGL ES custom coding in cocos2d ?
nope
(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.
Reference URL's