Ninjadoodle Posted September 4, 2018 Share Posted September 4, 2018 Hi @enpu Just trying game.scene.pause() with a timer and it doesn't seem to pause it. Just wondering whether this is a bug, or if I'm doing something wrong. Thank you! Quote Link to comment Share on other sites More sharing options...
enpu Posted September 4, 2018 Share Posted September 4, 2018 All timers that are running before you call game.scene.pause() should get paused. Can you show your code? Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted September 4, 2018 Author Share Posted September 4, 2018 Hi @enpu This is where I setup the timer ... game.module( 'game.game' ) .body(function() { game.createScene('Game', { init: function() { this.stageSetup = new game.StageSetup(); this.stageSetup.setupStage(); this.stageSetup.updateStage(); // TIMER this.countdownTxt = new game.Text('20'); this.countdownTxt.anchor.set(this.countdownTxt.width / 2, 0); this.countdownTxt.addTo(this.fg); this.countdownTxt.position.set(640, -0.5*(game.system.height - 1920) + 64); this.countdownTimer = game.Timer.add(10000, function() { // DO STUFF }); }, pad: function(number, length) { var str = '' + number; while (str.length < length) { str = '0' + str; } return str; }, update: function() { this.stageSetup.updateStage(); // TIMER var milliseconds = parseInt((this.countdownTimer.time()%1000)); var seconds = parseInt((this.countdownTimer.time()/1000)%60); this.countdownTxt.setText(this.pad(seconds, 2) + ":" + milliseconds); this.countdownTxt.anchor.x = this.countdownTxt.width / 2; this.countdownTxt.position.set(640, -0.5*(game.system.height - 1920) + 64); } }); }); The pause happens in the objects module, when clicking the 'settings' button ... game.module( 'game.objects' ) .body(function() { game.createClass('StageSetup', { setupStage: function() { // ************************ // *** SETUP CONTAINERS *** // ************************ game.scene.tv = new game.Container().addTo(game.scene.stage); game.scene.gm = new game.Container().addTo(game.scene.tv); game.scene.ui = new game.Container().addTo(game.scene.tv); game.scene.ux = new game.Container().addTo(game.scene.tv); game.scene.bg = new game.Container().addTo(game.scene.gm); game.scene.mg = new game.Container().addTo(game.scene.gm); game.scene.fg = new game.Container().addTo(game.scene.gm); game.scene.fader = new game.Fader(); game.scene.fader.speed = 500; game.scene.fader.sprite.interactive = true; game.scene.fader.fadeIn(); // ******************** // ***** SETTINGS ***** // ******************** game.scene.ui.visible = false; // BUTTONS SETTINGS game.scene.buttonSettings = new game.Sprite('buttonSettings.png'); game.scene.buttonSettings.position.set(1280, 0); game.scene.buttonSettings.anchor.set(192, 0); game.scene.buttonSettings.interactive = true; game.scene.buttonSettings.addTo(game.scene.gm); game.scene.buttonSettings.mousedown = function() { game.scene.pause(); game.scene.ui.visible = true; game.scene.settingsBg.interactive = true; game.scene.settingsButtonBack.interactive = true; game.scene.settingsButtonMusic.interactive = true; game.scene.settingsButtonAudio.interactive = true; if (game.system.sceneName === 'Main') { game.scene.settingsButtonInfo.interactive = true; } else { game.scene.settingsButtonHome.interactive = true; } }; // SETTINGS BACKGROUND game.scene.settingsBg = new game.Graphics(); game.scene.settingsBg.fillColor = '#000000'; game.scene.settingsBg.drawRect(0, 0, 2560, 2560); game.scene.settingsBg.anchorCenter(); game.scene.settingsBg.addTo(game.scene.ui); game.scene.settingsBg.position.set(640, 640); game.scene.settingsBg.interactive = false; game.scene.settingsBg.alpha = 0.5; // SETTINGS BUTTON BACK game.scene.settingsButtonBack = new game.Sprite('settingsButtonBack.png'); game.scene.settingsButtonBack.position.set(416, 416); game.scene.settingsButtonBack.anchorCenter(); game.scene.settingsButtonBack.interactive = false; game.scene.settingsButtonBack.addTo(game.scene.ui); game.scene.settingsButtonBack.mousedown = function() { game.scene.resume(); game.scene.ui.visible = false; game.scene.settingsBg.interactive = false; game.scene.settingsButtonBack.interactive = false; game.scene.settingsButtonMusic.interactive = false; game.scene.settingsButtonAudio.interactive = false; if (game.system.sceneName === 'Main') { game.scene.settingsButtonInfo.interactive = false; } else { game.scene.settingsButtonHome.interactive = false; } }; // SETTINGS BUTTON MUSIC game.scene.settingsButtonMusic = new game.Sprite('settingsButtonMusic.png'); game.scene.settingsButtonMusic.position.set(416, 864); game.scene.settingsButtonMusic.anchorCenter(); game.scene.settingsButtonMusic.interactive = false; game.scene.settingsButtonMusic.addTo(game.scene.ui); if (game.config.data.music) { game.scene.settingsButtonMusic.alpha = 1; } else { game.scene.settingsButtonMusic.alpha = 0.5; } game.scene.settingsButtonMusic.mousedown = function() { if (game.config.data.music) { game.config.data.music = false; this.alpha = 0.5; } else { game.config.data.music = true; this.alpha = 1; } this.scale.set(0.8); game.Tween.add(this.scale, { x: 1, y: 1 }, 100, { delay: 100, easing: 'Back.Out' }).start(); }; // SETTINGS BUTTON AUDIO game.scene.settingsButtonAudio = new game.Sprite('settingsButtonAudio.png'); game.scene.settingsButtonAudio.position.set(864, 864); game.scene.settingsButtonAudio.anchorCenter(); game.scene.settingsButtonAudio.interactive = false; game.scene.settingsButtonAudio.addTo(game.scene.ui); if (game.config.data.audio) { game.scene.settingsButtonAudio.alpha = 1; } else { game.scene.settingsButtonAudio.alpha = 0.5; } game.scene.settingsButtonAudio.mousedown = function() { if (game.config.data.audio) { game.config.data.audio = false; this.alpha = 0.5; } else { game.config.data.audio = true; this.alpha = 1; } this.scale.set(0.8); game.Tween.add(this.scale, { x: 1, y: 1 }, 100, { delay: 100, easing: 'Back.Out' }).start(); }; // SCENE SPECIFIC BUTTONS if (game.system.sceneName === 'Main') { // SETTINGS BUTTON INFO game.scene.settingsButtonInfo = new game.Sprite('settingsButtonInfo.png'); game.scene.settingsButtonInfo.position.set(864, 416); game.scene.settingsButtonInfo.anchorCenter(); game.scene.settingsButtonInfo.interactive = false; game.scene.settingsButtonInfo.addTo(game.scene.ui); // SETTINGS INFO POPUP game.scene.settingsInfoPopup = new game.Sprite('settingsQuitPopup.png'); game.scene.settingsInfoPopup.position.set(640, 640); game.scene.settingsInfoPopup.anchorCenter(); game.scene.settingsInfoPopup.interactive = true; game.scene.settingsInfoPopup.visible = false; game.scene.settingsInfoPopup.addTo(game.scene.ui); // SETTINGS INFO POPUP BUTTON X game.scene.settingsInfoPopupButtonX = new game.Sprite('settingsButtonInfo.png'); game.scene.settingsInfoPopupButtonX.position.set(352, -352); game.scene.settingsInfoPopupButtonX.anchorCenter(); game.scene.settingsInfoPopupButtonX.interactive = false; game.scene.settingsInfoPopupButtonX.addTo(game.scene.settingsInfoPopup); game.scene.settingsButtonInfo.mousedown = function() { game.scene.settingsInfoPopup.visible = true; game.scene.settingsInfoPopupButtonX.interactive = true; }; game.scene.settingsInfoPopupButtonX.mousedown = function() { game.scene.settingsInfoPopup.visible = false; game.scene.settingsInfoPopupButtonX.interactive = false; }; } else { // SETTINGS BUTTON HOME game.scene.settingsButtonHome = new game.Sprite('settingsButtonHome.png'); game.scene.settingsButtonHome.position.set(864, 416); game.scene.settingsButtonHome.anchorCenter(); game.scene.settingsButtonHome.interactive = false; game.scene.settingsButtonHome.addTo(game.scene.ui); // SETTINGS HOME POPUP game.scene.settingsHomePopup = new game.Sprite('settingsQuitPopup.png'); game.scene.settingsHomePopup.position.set(640, 640); game.scene.settingsHomePopup.anchorCenter(); game.scene.settingsHomePopup.interactive = true; game.scene.settingsHomePopup.visible = false; game.scene.settingsHomePopup.addTo(game.scene.ui); // SETTINGS HOME POPUP BUTTON O game.scene.settingsHomePopupButtonO = new game.Sprite('settingsButtonInfo.png'); game.scene.settingsHomePopupButtonO.position.set(-224, 256); game.scene.settingsHomePopupButtonO.anchorCenter(); game.scene.settingsHomePopupButtonO.interactive = false; game.scene.settingsHomePopupButtonO.addTo(game.scene.settingsHomePopup); // SETTINGS HOME POPUP BUTTON X game.scene.settingsHomePopupButtonX = new game.Sprite('settingsButtonInfo.png'); game.scene.settingsHomePopupButtonX.position.set(224, 256); game.scene.settingsHomePopupButtonX.anchorCenter(); game.scene.settingsHomePopupButtonX.interactive = false; game.scene.settingsHomePopupButtonX.addTo(game.scene.settingsHomePopup); game.scene.settingsButtonHome.mousedown = function() { game.scene.settingsHomePopup.visible = true; game.scene.settingsHomePopupButtonO.interactive = true; game.scene.settingsHomePopupButtonX.interactive = true; }; game.scene.settingsHomePopupButtonO.mousedown = function() { game.system.setScene('Main'); }; game.scene.settingsHomePopupButtonX.mousedown = function() { game.scene.settingsHomePopup.visible = false; game.scene.settingsHomePopupButtonO.interactive = false; game.scene.settingsHomePopupButtonX.interactive = false; }; } }, updateStage: function() { game.scene.tv.position.set(game.system.width / 2 - game.system.originalWidth / 2, game.system.height / 2 - game.system.originalHeight / 2); game.scene.offsetX = (game.system.width - game.system.originalWidth) / 2; game.scene.offsetY = (game.system.height - game.system.originalHeight) / 2; game.scene.buttonPosX = game.system.originalWidth + ((game.system.width - game.system.originalWidth) / 2); game.scene.buttonPosY = -1 * ((game.system.height - game.system.originalHeight) / 2); game.scene.buttonSettings.x = game.scene.buttonPosX; game.scene.buttonSettings.y = game.scene.buttonPosY; } }); }); Thank you! Quote Link to comment Share on other sites More sharing options...
enpu Posted September 4, 2018 Share Posted September 4, 2018 You are right. When pausing scene, current timers was not paused correctly (only their callback functions was skipped). This should be now fixed on dev branch, let me know if it works. Wolfsbane 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.