objective c - try to create CCSpriteFrame but get nil values -
i'm trying animate ccsprite in cocos2d v3 following question, i'm getting following error message in log:
terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[__nsarraym insertobject:atindex:]: object cannot nil'
this code:
nsmutablearray *animationframes = [nsmutablearray array]; int framecount = 0; for(int = 1; <= 9; ++i) { ccspriteframe *spriteframe = [[ccspriteframecache sharedspriteframecache] spriteframebyname: [nsstring stringwithformat:@"hero-%d.png", i]]; [animationframes addobject:spriteframe]; //error occur line framecount++; if (framecount == 8) break; }
the problem spriteframes nil, don't why. tested values nslog, , tried add hero-1.png ccsprite object , works fine. tried add fixed hero-1.png in frames verify if problem variable. didn't work also.
Comments
Post a Comment