Page 5 of 5

Re: My ongoing newbie questions

Posted: Mon Jun 22, 2009 10:28 pm
by essell
And another...

I have a physics body as the ground, with the player standing on it. How do I detect whether the player is touching the ground, to determine whether he can jump? Or is there a better way?

(At the moment, the player can keep jumping whilst in the air, as if they're flapping wings and flying upwards...)


[Edit] I've kind of hacked a solution to this, by checking the Y position of the player when they press the jump key, and not making him jump if he's too high. It seems quite crap though - is it more standard to do some kind of collision check between the player and the ground, and base it off that?

Re: My ongoing newbie questions

Posted: Tue Jun 23, 2009 1:05 pm
by bartbes
There are going to be callbacks not only when collision starts, but also when it stops, allowing you to use a simple ground boolean, in the mean time:
You can check if 1 pixel below the lowest point is in the ground, in that case, you're on the ground. (use testPoint on the shape)

Re: My ongoing newbie questions

Posted: Fri Jun 26, 2009 1:49 pm
by essell
Yeah, I've done something similar, cheers.

Q. How do I detect a collision between a bullet and an enemy?

Re: My ongoing newbie questions

Posted: Fri Jun 26, 2009 2:32 pm
by bartbes
Create the bullet as a physics entity and just fire it, you do need to set identification data and register a collision callback, but the docs of love.physics should help you with that. So basically it's the same as when you were firing other objects. :P