Here is what you do: first, you make a set of ground tiles. Make them whatever size you want. Then, mak another sort of tile: these should have the same width as the ground tiles, but be only one pixel high. Tile out the ground tiles in your level. Then, tile the othr tiles (call it topSense or something like that) so it's sitting just on top of the ground tile. It should be occupying th pixels just above the ground tiles, not the top row of the tiles. Your player has a collision event with the top side of the ground tiles (or any actor and check variables) which sets a jump variable to onGround (whatever value you want) and does the physical response. Add a collision finish event with the topSense tiles which sets the jump variable to inAir. In the player's draw actor, put a code the checks if you are in the air and yvelocity is less than a certain value, and increases the yvelocity:
- Code: Select all
if (jumpState == inAir && yvelocity < 30)
{
yvelocity += .5;
}
The good thing about this is that it only makes you fall when you are not on the platform, so ou aren't repeatedly calculating the collision. When you want to jump, check if the jumpState variable is onGround, and if it is, activate the jump code.
Hope this helps. If you have problems, just ask.