Wednesday, October 06, 2010

Sprite Sheets Management

How to Management Sprite ,with file .plits
Animation Frame Create and multiSprite ,

[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"runningman_coords.plist"];

// I presume this is where you load the first sprite?
CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:@"runningman1.png"];

sprite.position = ccp( s.width/2-80, s.height/2);

CCSpriteSheet *spritesheet = [CCSpriteSheet spriteSheetWithFile:@"runningman_textures.png"];

[spritesheet addChild:sprite];
[self addChild:spritesheet];

NSMutableArray *animFrames = [NSMutableArray array];
for(int i = 1; i < style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"runningman%d.png",i]];
[animFrames addObject:frame];
}

CCAnimation *animation = [CCAnimation animationWithName:@"run" delay:0.2f frames:animFrames];
[sprite runAction:[CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation:animation restoreOriginalFrame:NO] ]];

http://www.cocos2d-iphone.org/forum/topic/9939

No comments:

Video..

Loading...

Choose Referral Unit