Created
March 17, 2012 20:10
-
-
Save Sephi-Chan/2064869 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
ig | |
.module('game.entities.ui.pointer') | |
.requires( | |
'impact.entity' | |
) | |
.defines -> | |
window.EntityPointer = ig.Entity.extend | |
checkAgainst: ig.Entity.TYPE.BOTH | |
size: | |
x: 5 | |
y: 5 | |
zIndex: 100 | |
targetSomething: false | |
animSheet: new ig.AnimationSheet('media/cursor.png', 56, 56) | |
init: (x, y, settings)-> | |
@addAnim('idle', 0.2, [ 0, 1, 2, 3, 4 ]) | |
@parent(x, y, settings) | |
# Follow the mouse cursor. | |
update: -> | |
@pos.x = ig.input.mouse.x | |
@pos.y = ig.input.mouse.y | |
@isRightClicking = ig.input.pressed('rightClick') | |
@isLeftClicking = ig.input.pressed('leftClick') | |
@targetSomething = false | |
check: (other)-> | |
@targetSomething = true | |
if @isRightClicking or @isLeftClicking | |
if typeof other.handleClick is 'function' | |
other.handleClick() |
This file contains hidden or 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
ig.module('game.entities.ui.pointer').requires('impact.entity').defines(function() { | |
return window.EntityPointer = ig.Entity.extend({ | |
checkAgainst: ig.Entity.TYPE.BOTH, | |
size: { | |
x: 56, | |
y: 56 | |
}, | |
zIndex: 100, | |
targetSomething: false, | |
animSheet: new ig.AnimationSheet('media/cursor.png', 56, 56), | |
init: function(x, y, settings) { | |
this.addAnim('idle', 1, [0, 1, 2, 3, 4]); | |
return this.parent(x, y, settings); | |
}, | |
update: function() { | |
this.isRightClicking = ig.input.pressed('rightClick'); | |
this.isLeftClicking = ig.input.pressed('leftClick'); | |
return this.targetSomething = false; | |
}, | |
check: function(other) { | |
this.targetSomething = true; | |
if (this.isRightClicking || this.isLeftClicking) { | |
if (typeof other.handleClick === 'function') return other.handleClick(); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment