Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


#Actualwarnexus

Posted 18 April 2013 - 08:24 PM

Seems you start and set the game running (basically an eternity loop until members isLooping && isRunning is set to false) from the onMouseClick. OnMouseClick is probably called by some thread in Swings complex thred/event handling mechanism and you freeze it with your game loop. 

 

I would suggest that in event callback methods called by Swing you just set flags which hits the Game class what to do and then handle those flags in the main game loop instead.

event callback methods? You mean the mouseClicked method? Am I suppose to removeMouseListener of the buttons when the game is looping too? Is calling getInstance() in the mouseClicked wrong by any chance?


#2warnexus

Posted 18 April 2013 - 08:18 PM

Seems you start and set the game running (basically an eternity loop until members isLooping && isRunning is set to false) from the onMouseClick. OnMouseClick is probably called by some thread in Swings complex thred/event handling mechanism and you freeze it with your game loop. 

 

I would suggest that in event callback methods called by Swing you just set flags which hits the Game class what to do and then handle those flags in the main game loop instead.

event callback methods? You mean the mouseClicked method? Am I suppose to removeMouseListener of the buttons when the game is looping too? 


#1warnexus

Posted 18 April 2013 - 08:17 PM

Seems you start and set the game running (basically an eternity loop until members isLooping && isRunning is set to false) from the onMouseClick. OnMouseClick is probably called by some thread in Swings complex thred/event handling mechanism and you freeze it with your game loop. 

 

I would suggest that in event callback methods called by Swing you just set flags which hits the Game class what to do and then handle those flags in the main game loop instead.

event callback methods? You mean the mouseClicked method? Am I suppose to removeMouseListener of the buttons when the game is looping? 


PARTNERS