Cocos2d Part 3 (Actions)

 

+(CCScene *) scene
{
	CCScene *scene = [CCScene node];
	HelloWorldLayer *layer = [HelloWorldLayer node];
	[scene addChild: layer];
  	return scene;
}
-(void) finishCall{
    NSLog(@"finish_call");
}
-(id) init
{
	
	if( (self=[super init]) ) {
        CGSize windowSize = [[CCDirector sharedDirector] winSize];
        CCSprite *bird=[CCSprite spriteWithFile:@"bird.png" ];
        bird.position=ccp(windowSize.width/2, windowSize.height/2);
        id moveTo=[CCMoveTo actionWithDuration:0.9 position:ccp(300, 300)];//位移动画
        id rotateBy=[CCRotateBy actionWithDuration:0.9 angle:360];//旋转动画
        id callBack=[CCCallFunc actionWithTarget:self selector:@selector(finishCall)];//动画执行完回调
        [bird runAction:[CCSequence actions:moveTo,rotateBy,callBack, nil]];
        [self addChild:bird];

	}
	return self;
}

你可能感兴趣的:(cocos2d)