【iphone游戏开发】iphone-Cocos2d游戏开发之四:精灵实现缩放,旋转,跳动,移动等动画

// 增加动画
        
        // **缩放效果**
        id actionScale1 = [CCScaleBy actionWithDuration:2];
        id actionScale2 = [CCScaleBy actionWithDuration:2 scale:2.0f];
        id actionScale3 = [CCScaleBy actionWithDuration:2 scaleX:3.0f scaleY:3.0f];
        // CCScaleBy 为缩放动画,actionWithDuration为执行次数,scale为缩放的大小,正值为放大,负值为缩小,最后的scaleX,scaleY为在X,Y方向作缩放动作。
        
        // **旋转效果**
        id actionRotate1 = [CCRotateBy actionWithDuration:2];
        id actionRotate2 = [CCRotateBy actionWithDuration:2 angle:180.0f];
        //其他同上,只是增加了angle,旋转的角度。
        
        // **跳动效果**
        id actionJump1 = [CCJumpBy actionWithDuration:3];
        id actionJump2 = [CCJumpBy actionWithDuration:3 position:ccp(s.width/10, 0) height:20 jumps:3];
        // 其他同上,最后一个是在3秒内跳转到右下角,连续跳3次,每次高度为20
        
        // **同时执行旋转和跳动效果**
        id actionSpan = [CCSpawn actions:actionRotate2, actionJump2, nil];
        
        //以上的动作基本是有相反的动作的,可以通过reverse来作。
        id back = [actionSpan reverse];
        
        // **定制动画顺序**
        id actionSequence = [CCSequence actions:actionJump1,actionRotate1,actionScale1, nil];
        // **执行动画循环**
        id actionRepeat = [CCRepeat actionWithAction:back times:2];
        // **执行动画永久循环**
        id actionRepeatForever = [CCRepeatForever actionWithAction:actionSequence];
        
        //runAction 运行动画,你想要那个效果直接替换上面的动画即可。
        [sprite1 runAction:actionRepeat];
        
        //还有在运行过程的快慢
        [sprite2 runAction:[CCEaseIn actionWithAction:actionRepeat rate:2]];
//        [sprite2 runAction:[CCEaseOut actionWithAction:actionRepeat rate:3]];
//        [sprite2 runAction:[CCEaseInOut actionWithAction:actionRepeat rate:3]];
//        [sprite2 runAction:[CCEaseSineIn actionWithAction:actionRepeat]];
//        [sprite2 runAction:[CCEaseSineOut actionWithAction:actionRepeat]];
//        [sprite2 runAction:[CCEaseSineInOut actionWithAction:actionRepeat]];
//        [sprite2 runAction:[CCEaseExponentialIn actionWithAction:actionRepeat]];
//        [sprite2 runAction:[CCEaseExponentialOut actionWithAction:actionRepeat]];
//        [sprite2 runAction:[CCEaseExponentialInOut actionWithAction:actionRepeat]];
//        [sprite2 runAction:[CCSpeed actionWithAction:actionRepeat speed:(CCRANDOM_0_1() * 5)]];


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值