Starting to learn/write my first game using Corona/Solar2d game engine. And have a very basic question on how do people handle a such this situation which I assume should be common to any game engine.

I am trying to build an endless runner game, where I have an uneven terrain player have to jump between different height platforms while moving forward. Here is the closest to what I have in mind.


How do I find if the player has fallen between the the two platforms while jumping ?


A common way to solve this is to have an invisible "kill box" or "kill plane" near the bottom of your screen. If the player falls low enough to touch it, you know they missed a jump by so much that they can't recover, and it's time to count a failure.

This can take two common forms:

  • It can be a "trigger" collision object, that's one that can detect when other physics bodies touch it, but does not act as a solid obstacle that will push back against them or be pushed. In Solar2D terms, that's a fixture with isSensor set to true.

    You listen for collision events/callbacks from this object to detect when physics objects have touched the kill box, and react by destroying those objects or triggering a game over / restart.

  • Or it can be an implicitly-defined threshold that doesn't exist as an object in your physics world. Instead its a kind of "lethal altitude" value that you set. Each time you update your player, you check their y coordinate against this threshold. If they've fallen below the lethal altitude, time to die.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.