注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

熊猫正正的博客

熊猫正正的天空

 
 
 

日志

 
 

cocos2d-扩展动作  

2013-06-05 21:33:01|  分类: ios游戏开发 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

-(id) init

{

    self = [super init];

    if (self)

    {

        CGSize s = [CCDirector sharedDirector].winSize;

        CCSprite *sp = [CCSprite spriteWithFile:@"Space.png"];

        

        sp.opacity = 100;

        sp.position = ccp(s.width/2,s.height/2);

        sp.rotation = 90;

        

        [self addChild:sp z:0 tag:1];

        

        [CCMenuItemFont setFontName:@"Arial"];

        [CCMenuItemFont setFontSize:18];

        

        CCMenuItem *DelMenu = [CCMenuItemFont itemWithString:@"Delay" target:self selector:@selector(OnDelay:)];

        CCMenuItem *CalfMenu = [CCMenuItemFont itemWithString:@"Call func" target:self selector:@selector(OnCallFunc:)];

        CCMenuItem *CalfnMenu = [CCMenuItemFont itemWithString:@"Call func N" target:self selector:@selector(OnCallFuncN:)];

        CCMenuItem *CalfndMenu = [CCMenuItemFont itemWithString:@"Call func N D" target:self selector:@selector(OnCallFuncND:)];

        

        

        CCMenuItem *backMenu = [CCMenuItemFont itemWithString:@"Back" target:self selector:@selector(OnBackMenu:)];

        

        CCMenu *menu = [CCMenu menuWithItems:DelMenu,CalfMenu,CalfnMenu,CalfndMenu,backMenu, nil];

        [menu alignItemsVertically];

        

        menu.position = ccp(60,menu.position.y);

        

        [self addChild:menu z:1 tag:2];

        

        CCSpriteBatchNode *mgr = [CCSpriteBatchNode batchNodeWithFile:@"flight.png" capacity:5];

        [self addChild:mgr z:0 tag:4];

        

        sprite = [CCSprite spriteWithTexture:mgr.texture rect:CGRectMake(32*2, 0, 31, 30)];

        [mgr addChild:sprite z:1 tag:5];

        

        sprite.scale = 2.0;

        sprite.position = ccp(s.width/2,50);

    }

    

    return self;

}


- (void) OnDelay: (id) sender

{

    id ac1 = [CCMoveBy actionWithDuration:2 position:ccp(200,200)];

    id ac2 = [ac1 reverse];

    

    [sprite runAction:[CCSequence actions:ac1,[CCDelayTime actionWithDuration:1],ac2,nil]];

}


- (void) OnCallFunc: (id) sender

{

    id ac1 = [CCMoveBy actionWithDuration:2 position:ccp(200,200)];

    id ac2 = [ac1 reverse];

    

    id acf = [CCCallFunc actionWithTarget:self selector:@selector(CallBack1)];

    

    [sprite runAction:[CCSequence actions:ac1,ac2,acf,nil]];

}


- (void) CallBack1

{

    [sprite runAction:[CCTintBy actionWithDuration:0.5 red:255 green:0 blue:255]];

}


- (void) OnCallFuncN: (id) sender

{

    id ac1 = [CCMoveBy actionWithDuration:2 position:ccp(200,200)];

    id ac2 = [ac1 reverse];

    

    id acfn = [CCCallFuncN actionWithTarget:self selector:@selector(CallBack2:)];

    

    [sprite runAction:[CCSequence actions:ac1,ac2,acfn,nil]];

}


- (void) CallBack2: (id) sender

{

    [sender runAction:[CCTintBy actionWithDuration:1 red:255 green:0 blue:255]];

}


- (void) OnCallFuncND: (id) sender

{

    id ac1 = [CCMoveBy actionWithDuration:2 position:ccp(200,200)];

    id ac2 = [ac1 reverse];

    

    id acfnd = [CCCallFuncND actionWithTarget:self selector:@selector(CallBack3: data:) data:(void*)2];

    

    [sprite runAction:[CCSequence actions:ac1,acfnd,ac2,nil]];

}


- (void) CallBack3: (id) sender data: (void*) data

{

    [sender runAction:[CCTintBy actionWithDuration:(NSInteger)data red:255 green:0 blue:255]];

}


- (void) OnBackMenu: (id) sender

{

    [[CCDirector sharedDirector] replaceScene:[CCTransitionSlideInL transitionWithDuration:1.2f scene:[HelloWorldLayer scene]]];

}


- (void) dealloc

{

    [super dealloc];

}


  评论这张
 
阅读(71)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017