cocos2d 翻牌效果

主要采用CCOrbitCamera摄影机功能实现

-(void) testFlipCard
 {
     // create a sprite
     CCSprite *sprite1 = [CCSprite spriteWithFile: @"c1.png"];
     // set position of the sprite
     [sprite1 setPosition: ccp(240.0f, 160.0f)];
     
     // create an action
     id actionFunc1 = [CCSequence actions: 
                 [CCDelayTime actionWithDuration: 0.5f], 
                 [CCCallFuncN actionWithTarget: self selector: @selector(testFlipCardCallFunc1:)], 
                 [CCDelayTime actionWithDuration: 1.0f], 
                 [CCCallFuncN actionWithTarget: self selector: @selector(testFlipCardCallFunc2:)],
                 [CCDelayTime actionWithDuration: 0.5f], 
                 nil];
     id actionFlip1 = [CCOrbitCamera actionWithDuration: 2.0f 
                                                 radius: 1.0f 
                                            deltaRadius: 0.0f 
                                                 angleZ: 0.0f 
                                            deltaAngleZ: -360.0f 
                                                 angleX: 0.0f 
                                            deltaAngleX: 0.0f];
     id actionForever1 = [CCRepeatForever actionWithAction: [CCSpawn actions: 
                          actionFunc1, actionFlip1, nil]];
     
     // run action
     [sprite1 runAction: actionForever1];
     // add the sprite to the layer
     [self addChild: sprite1];
     
     // create a sprite
     CCSprite *sprite2 = [CCSprite spriteWithFile: @"c0.png"];
     // set position of the sprite
     [sprite2 setPosition: ccp(240.0f, 160.0f)];
     // hide sprite 2
     [sprite2 setVisible: NO];
     
     // create an action
     id actionFunc2 = [CCSequence actions: 
                 [CCDelayTime actionWithDuration: 0.5f], 
                 [CCCallFuncN actionWithTarget: self selector: @selector(testFlipCardCallFunc2:)], 
                 [CCDelayTime actionWithDuration: 1.0f], 
                 [CCCallFuncN actionWithTarget: self selector: @selector(testFlipCardCallFunc1:)], 
                 nil];
     id actionFlip2 = [CCOrbitCamera actionWithDuration: 2.0f 
                                                 radius: 1.0f 
                                            deltaRadius: 0.0f
                                                 angleZ: 0.0f
                                            deltaAngleZ: -360.0f 
                                                 angleX: 0.0f 
                                            deltaAngleX: 0.0f];
     id actionForever2 = [CCRepeatForever actionWithAction: [CCSpawn actions: 
                          actionFunc2, actionFlip2, nil]];
     // run action
     [sprite2 runAction: actionForever2];
     // add the sprite to the layer
     [self addChild: sprite2];
 }
 
 -(void) testFlipCardCallFunc1 : (id) node
 {
     [node setVisible: NO];
 }
 
 -(void) testFlipCardCallFunc2 : (id) node
 {
     [node setVisible: YES];
 }

07163155_4m9H.png

07163155_d4iT.png

转载于:https://my.oschina.net/robslove/blog/275947

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值