Or hitTestPoint for a better result non flat terrain (like if you wanted slops this could let the player walk up the slope just fine and if you have a gravity var it will allow the player to walk down the ramp)
player.y – -
I just don’t understand how you stop them falling. Yes you test hitTestObject but how do you keep it up. It’s really confusing me
Well, that depends of your game. Using a loop (like in evan999333’s post) to lower player’s y until it no longer collides is a good idea, but obviosly you have to adapt it to your game’s parameters (ex: setting the falling speed to 0, letting the player to jump, etc)
How do I stop my player falling though a floor for them to like move around (platformer)
You know what needs to be done. You need to detect when the character hits the floor and stop it from falling. Explicitly, with as many lines of code as needed. Nothing will happen by magic. The computer will do everything you tell it to do (and exactly that) but it will do nothing more.
Hey, do you like games? So do we — that’s what makes Kongregate the best source of free games online. We have thousands upon thousands of free online games, from both one-man indies and large studios, rated and filtered so you can play the best of the best. Read more »