cocos2d的跳跃动画及放大器;移动 [英] Cocos2d Jump Animation & Moving

查看:245
本文介绍了cocos2d的跳跃动画及放大器;移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我能够控制我的精灵的一边到另一边的运动与在cocos2d按钮。我现在试图将一个跳跃的动画,但我完全不知道如何做到这一点。我试图利用它在init方法相结合,动画(跳起来跳了下去),但每当我尝试,而这是我跳得到了SIGABRT错误移动精灵一个样本code。请注意,我感到非常雏与cocos2d的和走在我一步步地成为一个成功的跳跃的动画将大大AP preciated。

So far I am able to control my sprite's side to side movement with buttons in Cocos2d. I am now trying to incorporate a jump animation but I have absolutely no idea how to do this. I have tried one sample code which utilized the init method and combined to animations (jump up and jump down) but whenever I tried to move the sprite while it was jumping i got a SIGABRT error. Please note that I am very unexperienced with Cocos2d and walking me through the steps to make a successful jump animation would be greatly appreciated.

推荐答案

CCJumpBy模拟抛跳动作。

CCJumpBy simulates a parabolic jump movement.

id jump_Up = [CCJumpBy actionWithDuration:1.0f position:ccp(0, 200) height:50 jumps:1];

运行上面的jump_Up行动将通过'0'沿X轴沿Y轴200'units距离和'移动精灵的位置,并会沿抛物线路径移动精灵。

Running the above jump_Up action will move the sprite's position by '0' distance along x axis and '200'units along y axis and will move the sprite along a parabolic path.

如果你想移动精灵权利或跳跃时离开。请尝试以下..

If you wish to move the sprite right or left while jumping. Try the following..

CGPoint newPosition = ccp(max(sprite.position.x + screenSize.width * 0.2f,screenSize.width), sprite.position.y);
id jumpAct = [CCJumpBy actionWithDuration:1.0f position:newPosition height:50 jumps:1];
[sprite runAction:jumpAct];

这篇关于cocos2d的跳跃动画及放大器;移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆