Landing sound?

T

tamation

Guest
I've been trying to program a landing sound into my 2D platformer game.
I've gotten the jump sound down fine, but when it comes to a landing sound I'm pretty much stuck.

I want it so that the sound only plays once the player touches the ground.
I've tried all sorts of different things in code, but nothing seems to be working. The sound either constantly plays while they're on the ground, or it also plays when they hit the ceiling.

Does anyone know how to do this?
 

obscene

Member
Make a landed variable set to the opposite of your free variable. When they match you know it's time to play a sound.

Code:
if !free && !landed  // Not free and not landed
  {
  play_sound=true;
  }
landed=!free; // Set landed to opposite of free
 
Top