Carry out the following steps:
Open the
audiogame.js
JavaScript file.Add the following code in the jQuery ready function:
$(audiogame.melody).bind('ended', onMelodyEnded);
Add the following event handler function at the end of the file:
// show game over scene on melody ended. function onMelodyEnded() { console.log('song ended'); alert ('success percent: ' + audiogame.totalSuccessCount / audiogame.totalDotsCount * 100 + '%'); } })(jQuery);
It is time to save all files and play the game in a web browser. When the game is over, we should see a pop-up alert with the successful rate.