首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

CCAnimation延续动画播放

2013-10-24 
CCAnimation连续动画播放////Player.m//Test2////Created by rayln on 13-9-29.//Copyright 2013年 __MyCo

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

热点排行