Stephen M. Yantz
Stephen M. Yantz

Reputation: 31

Corona SDK: Want to change scene when audio ends. (not working)

So I have this set up. The sound works. The endGame function also works if the function is called directly, in the scene:create( event ). But when I call the function from the onComplete method in the sound, the function triggers, but the i get this message "attempted to call a nil value" after the sound stops playing.

media.playSound( quotepath, {onComplete = endGame } )

the function:

function endGame()
composer.gotoScene( "scenes.gameover", "fade", 500 )
end

Upvotes: 0

Views: 63

Answers (1)

Kumar KS
Kumar KS

Reputation: 521

This how the syntax should be of,

 local onComplete

 onComplete = function(event)
    print( "sound play ended" )

end

media.playSound( "song1.mp3", onComplete )

Upvotes: 1

Related Questions