Skip to content

Instantly share code, notes, and snippets.

@morukutsu
Created July 3, 2015 08:50
Show Gist options
  • Save morukutsu/24b05977a44abd429ee4 to your computer and use it in GitHub Desktop.
Save morukutsu/24b05977a44abd429ee4 to your computer and use it in GitHub Desktop.
/**
* client
* Mouse.js - Advanced mouse states (clicked...)
*/
define(
// Includes
[
],
function() {
var Mouse = function() {
/**
* Mouse states
*/
this.isDown = false;
this.isClicked = false;
};
Mouse.prototype.update = function() {
// Previous state for the isClicked event
this.wasDown = this.isDown;
this.isDown = this.game.input.activePointer.isDown;
this.isClicked = this.isDown && !this.wasDown;
};
return Mouse;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment