读书人

CCAnimation延续动画播放

发布时间: 2013-10-24 18:27:21 作者: rapoo

CCAnimation连续动画播放

////  Player.m//  Test2////  Created by rayln on 13-9-29.//  Copyright 2013年 __MyCompanyName__. All rights reserved.//#import "Player.h"@implementation Player- (id)init{    self = [super init];    if(self){                CCSpriteBatchNode* path = [CCSpriteBatchNode batchNodeWithFile:@"player.png"];        [self addChild:path z:0 tag:0];        CCSprite* man = [CCSprite spriteWithTexture:[[path textureAtlas] texture] rect:CGRectMake(0, 0, 24, 32)];        [man setPosition:CGPointMake(150, 150)];        [self addChild:man];                NSMutableArray* arr = [NSMutableArray array];        for (int y=0; y<4; y++) {            for (int x=0; x<3; x++) {                CCSpriteFrame* frame = [CCSpriteFrame frameWithTexture:[[path textureAtlas] texture] rect:CGRectMake(x*24, y*32, 24, 32)];                [arr addObject:frame];            }        }        CCAnimation* animation = [CCAnimation animationWithSpriteFrames:arr delay:.1];        CCAnimate* animate = [CCAnimate actionWithAnimation:animation];        CCRepeatForever* repeat = [CCRepeatForever actionWithAction:animate];        [man runAction:repeat];    }    return self;}@end

读书人网 >移动开发

热点推荐