Reputation: 3991
I have a simple example where I'm applying an impulse to a node on touch like so :
[_bird.physicsBody applyImpulse:CGVectorMake(0, 15)];
What I want is to apply a "static" impulse.
Let me explain :
When my node is in a falling phase, due to gravity, applying an impulse will be harder and the impulse will apply a dy
of 5 instead of 15 (for example).
In another case, when my node is not falling (i.e is on the ground), if I tapped multiple time quickly, my impulse seems to be multiplied and not being added, causing my node to reach the "roof" way too fast.
I want to apply the same number of dy
, whenever the case.
Is there anyway to do that ?
Thanks in advance for your help.
Upvotes: 1
Views: 3034
Reputation: 20274
In order to make the impulse have the same effect on the sprite node regardless of it's state, you could try setting it's velocity
property to zero. Like so:
_bird.physicsBody.velocity = CGVectorMake(0,0);
[_bird.physicsBody applyImpulse:CGVectorMake(0, 15)];
This should make the 'bird' (Flappy Bird?) behave the same way in the any situation.
Upvotes: 14