How can I use more than one sprite sheet? cocos2d/iPhone -
i'm trying use more 1 sprite sheet because can't fit them on 1 , having 2 makes ordering them easier (sprite sheet 1 sprites in , have lower zorder). i'm doing:
spritesheet1 = [[ccspritesheet spritesheetwithfile:@"spritesheet1.png" capacity:3] retain]; [[ccspriteframecache sharedspriteframecache] addspriteframeswithfile:@"spritesheet1.plist"]; [self addchild:spritesheet1]; spritesheet2 = [[ccspritesheet spritesheetwithfile:@"spritesheet2.png" capacity:4] retain]; [[ccspriteframecache sharedspriteframecache] addspriteframeswithfile:@"spritesheet2.plist"]; [self addchild:spritesheet2]; ccsprite *sprite = [ccsprite spritewithspriteframename:@"sprite1.png"];
the last line crashes error: terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'invalid spriteframe sprite' sigabrt
am not allowed cache more 1 sprite sheet? if not, there efficient way handle this?
if create spritesheets using zwoptex, make sure use version of zwoptex , cocos2d support each other. there have been major changes zwoptex , if you're using older cocos2d version might explain crash.
in general code provided should work fine, given resource files haven been added xcode , named properly. keep in mind ios devices case-sensitive, if try load "spritesheet1.plist" file named "spritesheet1.plist" lead errors (probably assertion or crash).
Comments
Post a Comment