• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

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