If you want to make your Sprite move in a parabolic path or projectile path then you are in right place. I am going to explain how to do it simply.
You can do it using CCJumpBy action.
Let your sprite position is (0,0), You want to jump it to position (100,0) with a maximum height of 50.
Let me explain now-
actionWithDuration : 1 - is the time required to reach the destination or simply your action time.
postion : ccp(x,y) - is the position you want to see your sprite at the end. In our case it is (100,0).
height : h - is the maximum height it will reach during jump. In our case it is 50.
jumps : 1 - it is the number of jumps it will do to reach the destination. For a projectile or parabolic path it is tend to be 1.
You may play around with it to see the results and effects.
You can do it using CCJumpBy action.
Let your sprite position is (0,0), You want to jump it to position (100,0) with a maximum height of 50.
id jump = [CCJumpBy actionWithDuration:1 position:ccp(100, 0) height:50 jumps:1]; [sprite runAction:jump];
Let me explain now-
actionWithDuration : 1 - is the time required to reach the destination or simply your action time.
postion : ccp(x,y) - is the position you want to see your sprite at the end. In our case it is (100,0).
height : h - is the maximum height it will reach during jump. In our case it is 50.
jumps : 1 - it is the number of jumps it will do to reach the destination. For a projectile or parabolic path it is tend to be 1.
You may play around with it to see the results and effects.
Thanks! In my case I just wanted to see the sprite jumping up and down in the same place, so I just set the position as ccp(0,0).
ReplyDelete