Animation with large number of sprites in Cocos2d iOS? -
i have animate(dancing) character(guy) 6-7 seconds i.e 500-600 frames. have done animation before creating spritesheets using zwoptex , loading ccspriteframecache && ccspritebatchnode of the great ray wenderlich. in case frames heavy in number not sure if ios device able sustain it. best process animate these frames little overhead possible. can change fps while animating? idea anyone??
here put code use add animated image without use texturepacker:
ccsprite *dog = [ccsprite spritewithfile:@"dog1.gif"]; dog.position = ccp(winsize.width/2, winsize.height/2); [self addchild:dog z:2]; nsmutablearray *animframes = [nsmutablearray array]; for( int i=1;i<=5;i++) { nsstring* file = [nsstring stringwithformat:@"dog%d.gif", i]; cctexture2d* texture = [[cctexturecache sharedtexturecache] addimage:file]; cgsize texsize = texture.contentsize; cgrect texrect = cgrectmake(0, 0, texsize.width, texsize.height); ccspriteframe* frame = [ccspriteframe framewithtexture:texture rect:texrect]; [animframes addobject:frame]; } ccanimation * animation = [ccanimation animationwithspriteframes:animframes]; animation.delayperunit = 0.07f; animation.restoreoriginalframe = yes; ccanimate *animaction = [ccrepeatforever actionwithaction:[ccanimate actionwithanimation:animation]]; [dog runaction:animaction];
try code, i'm not sure might helpful in case:
Comments
Post a Comment