Jump to content

sprite animation - movement sound effect?


specialspam
 Share

Recommended Posts

Hello,

 

I am completely new to Phaser and have just been mucking around with a simple platform canvas and character. I was able to add music and a 'boing' sound for when the character jumps, however, I cannot figure out how to approach adding a walking sound properly when the character walks left or right. With the code below it plays the sound over itself on every update call so when the key is pressed down it just comes out as a loud 'blaarrrrrrr'

 

I have been searching the forums, examples and documentation but just haven't found anything...

 

Does anyone have any tips or pointers they could throw my way?

 

Here is how I load the sound:

foot = game.add.audio('foot',1,false);

I added the sound in the move left keyboard detection which plays my sprites animation and moves him:

if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))    {        //  Move to the left        player.body.velocity.x = -200;        player.animations.play('left');        foot.play('',0,1,false);    }

Should I be setting up the audio in the animation setup under the create function OR should I limit the amount of times it gets played? sorry I am just a lost beginner!

 

Thanks in advance.

 

Specialspam.

 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...