need help in understanding sprite animation for cocos2d? -



need help in understanding sprite animation for cocos2d? -

i using next code sprite animation in cocos2d

[[ccspriteframecache sharedspriteframecache] addspriteframeswithfile: @"animbear.plist"]; ccspritebatchnode *spritesheet = [ccspritebatchnode batchnodewithfile:@"animbear.png"]; [self addchild:spritesheet]; nsmutablearray *walkanimframes = [nsmutablearray array]; for(int = 1; <= 8; ++i) { [walkanimframes addobject: [[ccspriteframecache sharedspriteframecache] spriteframebyname: [nsstring stringwithformat:@"bear%d.png", i]]]; } ccanimation *walkanim = [ccanimation animationwithframes:walkanimframes delay:0.1f]; cgsize winsize = [ccdirector shareddirector].winsize; self.bear = [ccsprite spritewithspriteframename:@"bear1.png"]; _bear.position = ccp(winsize.width/2, winsize.height/2); self.walkaction = [ccrepeatforever actionwithaction: [ccanimate actionwithanimation:walkanim restoreoriginalframe:no]]; [_bear runaction:_walkaction]; [spritesheet addchild:_bear];

i need not getting clear thought ccspritebatchnode why used here?

you not need utilize ccspritebatchnode single animation.

the ccspritebatchnode used when want display many objects taken same sprite sheet. in case rendering stuff much faster rendering individual sprites. long utilize single sprite there no speed since sprites in animation displayed in separate frames.

cocos2d-iphone

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -