tux4kids / Tux4ME

A mind exercise game by Tux4Kids organization developed under Google summer of Code - 2015
GNU General Public License v3.0
19 stars 28 forks source link

added keyboard controls and game.paused function to the updated files #11

Closed Deepaksharm closed 8 years ago

Vigneshsekar commented 8 years ago

This pull request was affecting the change made in the previous one (Fixed the Bug in "Click here to finish the game" button ).

AkshayAgarwal007 commented 8 years ago

@Vigneshsekar , were you referring to this pull request regarding the game.paused functionality? There is no any relevance of blindly replacing the pause state variable with game.paused. This won't work. For e.g take the case of replay function in catchflow.js. The point where the pauseState=1 has been replaced by game.paused==true the game is paused, according to the phaser docs all the subsystems gets paused and the only way one can come out of this is by creating a callback to an unpause function by binding it to the input.onDown event of the game object. Now if one wants the user to resume the game by clicking on the pause button again then the mouse pointer's position when the unpause function is called has to be detected and checked that whether it is inside the boundaries of the pause button or not.

So what you were doing was storing an integer value in a pause state variable and were blocking calls to certain functions depending on the value but using game.paused in the same way can't work, when he is declaring game.paused==true inside the pauseAndPlay, the game is paused, the subsystems are paused, the pause object won't listen to any user clicks. Also in the replay function when he is declaring game.paused==true the game is paused and everything is locked there and one can't come out of it

I would like @Deepaksharm to explain me this code and correct me if I'm wrong.