Movement and sound question


(Nate ) #1

Hey guys! So I had a decent movement system down, and I wanted to add some foot steps, which I did; then I wanted to add different footsteps for different surfaces! Which I did!

The only problem I was having was once the player would jump and land, the footsteps were gone, now don’t jump down my throat yet, it was some sort of boolean problem (go figure)

So I decided to try to re-write my movement and sound code a lot cleaner and easier to modify if need be… Currently to make this as pain free as possible, I am working with just the left arrow key input, and one of my ground types.

The code that I am including here is from the update function, and right now, the player moves left, but for some reason the sound does not play until I release the key. I am not sure what the issue is and have been scratching my head at this for the past hour or so… lol

Here is my code:

			if (ySpeed == 0)
		{
		isOnGround = true;
		}
		else
		isOnGround = false;
		
		
		if (Input.check(Key.LEFT))
		{
			xSpeed-=power;
			pressed = true;
			playerSprite.play("goingLeft");
			
			
			if(isOnGround && xSpeed != 0 && collide("grass",x,y + 1))//if the character is on the ground and moving
			{
			sfxStep.play(.05);
			sfxStep.loop();
			}
			else
			sfxStep.stop();
			
		}

Thanks guys!