Chapter 2, Exercise 1 – Removing Click Handlers

If you click in the game area a second time, the bubble appears back on the screen. How would you disable this click event to prevent it?

The simplest way is to unbind the event handler in the clickGameScreen function in game.js:

var clickGameScreen = function(e){
  $("#game").unbind("click",clickGameScreen);
  var angle = BubbleShoot.ui.getBubbleAngle(curBubble.getSprite(),e);
  …
}

See the jQuery documentation on unbinding for more: http://api.jquery.com/unbind/

Leave a Reply

Your email address will not be published. Required fields are marked *