O'Reilly logo

Developing Mobile Games with Moai SDK by Francisco Tufro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sound effects

We will add a sound that will be played when the character jumps.

Open up character.lua and add a call to AudioManager:play inside Character:jump:

function Character:jump ( keyDown )
    if keyDown and not self.jumping then
        AudioManager:play ( 'jump' )
        self.physics.body:applyForce ( 0, 8000 )
        self.jumping = true
        self:startAnimation ( 'jump' )
    end
end

That's it. Run it and listen to your jump.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required