回调函数的使用实例(10.27)

本文介绍了 Cocos2d-x 中动画的使用及回调函数的应用实例。通过 runAction 方法实现动画效果,并结合 CCSequence 和 CCCallFunc 控制动画序列及触发特定方法。同时展示了如何在动画结束后停止所有动作并设置最终帧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

回调函数实例:

 

-(void)runtelephoneing{

 

[self runAction:[CCRepeatForever actionWithAction:[[GameLogic ShareGameLogic] Get_animate:17]]];

}

 

 

-(void)runpicking{

 

[self runAction:[CCSequence actions:[[GameLogic ShareGameLogic] Get_animate:16],[CCCallFunc actionWithTarget:self selector:@selector(runtelephoneing)],nil]];

}

或者

 

-(void)actionyun{

 

if (_delegate && [_delegate respondsToSelector:@selector(runpunishing:)]) {

[_delegate runpunishing:_type];

}

((CCSprite*)[self getChildByTag:TAG_YUN]).visible = YES;

id action = [[GameLogic ShareGameLogic] Get_animate:TAG_YUN];

[[self getChildByTag:TAG_YUN] runAction:action];

}

 

 

-(void)actionnode{

 

id actionfall = [CCMoveTo actionWithDuration:0.5f position:_pointend];

id actioncallyun = [CCCallFunc actionWithTarget:self selector:@selector(actionyun)];

id actionup = [CCMoveTo actionWithDuration:0.5f position:_pointbegan];

id actioncall = [CCCallFunc actionWithTarget:self selector:@selector(delete)];

id actionfright=[CCCallFunc actionWithTarget:self  selector:@selector(actionfrighten)];

 

id actionseq = [CCSequence actions:actionfright,actionfall,actioncallyun,actionup,actioncall, nil];

[[self getChildByTag:TAG_FALL] runAction:actionseq];

 

结束帧并且画面停留的:

CCSprite *zj=(CCSprite*)[self getChildByTag:_TAG_ZJ];

[zj stopAllActions];

[zj setDisplayFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"zj_kan_00.png"]];

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值