melonJS icon indicating copy to clipboard operation
melonJS copied to clipboard

onPause Callback Not Triggered in me.state.pause

Open aaschmitz opened this issue 14 years ago • 2 comments

HI

Currently the onPause callback is defined in the EventListener "blur":

// set pause action on losing focus $.addEventListener("blur", function() { // only in case we are not loading stuff if (me.sys.pauseOnBlur && (_state != obj.LOADING)) { obj.pause(true); } // callback? if (obj.onPause) obj.onPause(); ...

But the same is not in the pause function:

obj.pause = function(music) { // stop the main loop _stopRunLoop(); // current music stop if (music) me.audio.pauseTrack(); };

The right would move the function callback from EventListener to obj.pause? The same logic is valid for the "resume" function.

Thanks!

aaschmitz avatar Oct 06 '12 03:10 aaschmitz

Hmm, doesn't it seem kind of silly to expect your callback to fire when your code calls me.state.pause? Your code can also fire the callback at the same time.

parasyte avatar Oct 06 '12 04:10 parasyte

I agree with parasyte, since you are directly calling the me.state.pause() function, you can also call any other function :)

ghost avatar Oct 08 '12 05:10 ghost