jclyra Posted October 11, 2016 Share Posted October 11, 2016 Hi, I'm really new to phaser and having some issues with my game on which I created a script that when the player clicks or goes outside of the game (e.g. clicks another tab), the music should be paused and when it resumes (user clicks back in game), music should continue. The issue is that when the game continues, it music starts over the very beginning. I've followed some of the examples that I've found here but still does not work. Anyone experiencing the same thing or it's juts with my implementation? var introState = function(game){ }; introState.prototype = { preload: function(){ game.load.audio('intro', '../music/intro.mp3'); }, create: function(){ recording = game.add.audio('intro'); recording.play(); game.onPause.add(pauseMusic, this); game.onResume.add(resumeMusic, this); }, render: function(){ } } function pauseMusic() { recording.pause(); } function resumeMusic() { recording.resume(); } This is just one of a state with in my game. Any help is appreciated. Thanks Link to comment Share on other sites More sharing options...
Alexalten Posted October 11, 2016 Share Posted October 11, 2016 Hi, try using the following example: http://phaser.io/examples/v2/misc/pause-menu In this example, there is a "game.paused = true;" that freeze the entire game (in my game also the music). Bye, Alex Link to comment Share on other sites More sharing options...
jclyra Posted October 11, 2016 Author Share Posted October 11, 2016 Hey, Appreciate your Alex reply. But something is really weird. I tested the code here at home and it works perfectly fine. Maybe this is a browser issue. I will try to compare my browser here at home and at the office. Link to comment Share on other sites More sharing options...
Recommended Posts