smdu57 Posted May 3, 2017 Share Posted May 3, 2017 Hello I have a problem. I want my player when he is in front of a bottle and when he interract with it (up arrow key) the frame of the bottle change. The problem is I use an overlap between player and bottle I use : if (cursors.up.isDown) { bouteille.frame = bouteille.frame +1; } but when in game I press the up key it change all frame in one ms. How can I set a timer or something to say I pressed one time I need to release key and do it only after repressed Thanks Link to comment Share on other sites More sharing options...
smdu57 Posted May 4, 2017 Author Share Posted May 4, 2017 Please can you help me I don't know how to do it and I'm kind of stuck without it resolve. Link to comment Share on other sites More sharing options...
smdu57 Posted May 4, 2017 Author Share Posted May 4, 2017 Well I found something interesting, if I use an alert just like that : if (cursors.up.isDown && points > 0) { alert(); bouteille.frame = bouteille.frame +1; } It make exactly what I want, a break between two pressed key. The problem is there is a popup and you should close it before continuing the game. So is there any way to make an alert without popup or just a kind of break or sleep in program ? Link to comment Share on other sites More sharing options...
smdu57 Posted May 5, 2017 Author Share Posted May 5, 2017 I figured out myself I just added a variable in the if statement, this variable is set to 1 then the function inside the if set it to 0 and I added a eventListener onUp that change this var to 1 and it worked Link to comment Share on other sites More sharing options...
Recommended Posts