BadBearGames Posted March 1, 2014 Share Posted March 1, 2014 Hey guys, first time posting here. I have a black background sprite that appears when my game is paused to fade out the screen. In the create function I create it, set its alpha to 0.5, and set its visible value to false (I also put the body to null if that makes a difference). When the paused button is pressed, I set its visible property to true and pause the game. In my update function I set its visible to false, so that when the game isn't paused, the background is hidden. For some reason this doesn't work the first time I pause the game, but it works every time after that. It just really bothers me. Is there something I'm missing? Thank you. Link to comment Share on other sites More sharing options...
Kobaltic Posted March 1, 2014 Share Posted March 1, 2014 Hard to tell without posting some code. Link to comment Share on other sites More sharing options...
BadBearGames Posted March 2, 2014 Author Share Posted March 2, 2014 //I have a lot of code, so I just put in the lines related to the problem//I'm using the full screen mobile templatecreate: function() {pausedFade_mc = this.add.sprite(0, 0, 'background1');pausedFade_mc.anchor.setTo(0.5, 0.5);pausedFade_mc.scale.setTo(4, 4);pausedFade_mc.alpha = 0.5;pausedFade_mc.visible = false;pausedFade_mc.body = null;}'update: function() {if (pausedFade_mc){ paused_txt.visible = false; pausedFade_mc.visible = false;}},function pauseGame() { //Pauses the game when called paused_txt.visible = true; paused_txt.x = playerBody_mc.x; paused_txt.y = playerBody_mc.y + 200; pausedFade_mc.visible = true; pausedFade_mc.alpha = 0.5; pausedFade_mc.x = playerBody_mc.x; pausedFade_mc.y = playerBody_mc.y; thisGame.paused = true;}@Kobaltic There you go Link to comment Share on other sites More sharing options...
LeonardoDigital Posted April 4, 2014 Share Posted April 4, 2014 @BadBearGames: Hi. I cant give you a solution to your problem, I m really new to programming. but I m very curious to know how do you unpause your game? I havent found a way to do it. Easy to pause and hard to unpause. Thanx. Link to comment Share on other sites More sharing options...
TomFiveThumbs Posted April 4, 2014 Share Posted April 4, 2014 Maybe pauseGame is being called before update? Setting it to visible, then instantly back to invisible? Something may be tripping up the code the first time it happens. Something might not be loaded in properly until the first time... This is all speculation really. Maybe set up some console.log flags to keep track of when exactly the visible property is changed. Link to comment Share on other sites More sharing options...
adamyall Posted April 4, 2014 Share Posted April 4, 2014 I didn't test your code, but I think the answer may simply be that you are trying to run pause/resume code unconventionally.Here is a working fiddle that shows how to add event handlers to the pause event. You can actually add as many as you want! Much easier to manage.http://jsfiddle.net/adamholdenyall/LLddd/1/ TomFiveThumbs 1 Link to comment Share on other sites More sharing options...
LeonardoDigital Posted April 4, 2014 Share Posted April 4, 2014 @adamyall: Thank you for sharing your code. Link to comment Share on other sites More sharing options...
Recommended Posts