1 decade ago by jessefreeman
So I am setting up a few screens for my game. I basically extend ig.Game class for each screen (start, game, gameover) and when I need to I call ig.system.setGame to switch between them. This works great except when I added in a "Press spacebar to continue" option. Right now when I go from my start screen to my game it works but for some reason my "continue" state never gets set to false after I set the new game. So when a game runs if I test for
it's always true. Here is an example of my binding and logic for detecting a continue:
I tried calling clearedPressed and even doing unbinding in the Input class but nothing is resetting it. The only way I was able to fix this was by manually clearing the Input actions property like this
before I switch to a new screen. I find this kind of hacky and wanted to make sure I wasn't missing something? If I don't do this, when the player dies and goes to the game over screen it immediately jumps to the start screen then to the main game since "continue" is always true.
This isn't the end of the world but it appeared to be a bug to me. I expected clearPressed to work but it didn't. Maybe I need to put in some kind of delay before setting the next game? I have noticed a lot of accidental endless looping if I wasn't careful on exactly when I executed something in my code. I also tested this with other buttons like x or c and ran into the same issue.
Any help on this would be appreciated.
if(ig.input.state('continue'))
it's always true. Here is an example of my binding and logic for detecting a continue:
init: function() { ig.input.bind( ig.KEY.SPACE, 'continue'); }, update: function() { if(ig.input.state('continue')){ ig.system.setGame(MyGame); } this.parent(); },
I tried calling clearedPressed and even doing unbinding in the Input class but nothing is resetting it. The only way I was able to fix this was by manually clearing the Input actions property like this
update: function() { if(ig.input.state('start')){ ig.input.actions = {}; ig.system.setGame(MyGame); } this.parent(); },
before I switch to a new screen. I find this kind of hacky and wanted to make sure I wasn't missing something? If I don't do this, when the player dies and goes to the game over screen it immediately jumps to the start screen then to the main game since "continue" is always true.
This isn't the end of the world but it appeared to be a bug to me. I expected clearPressed to work but it didn't. Maybe I need to put in some kind of delay before setting the next game? I have noticed a lot of accidental endless looping if I wasn't careful on exactly when I executed something in my code. I also tested this with other buttons like x or c and ran into the same issue.
Any help on this would be appreciated.