Created
July 3, 2015 08:50
-
-
Save morukutsu/24b05977a44abd429ee4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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