Provides the entity with mouse related events
Crafty adds the mouseButton property to MouseEvents that match one of
- Crafty.mouseButtons.LEFT
- Crafty.mouseButtons.RIGHT
- Crafty.mouseButtons.MIDDLE
myEntity.bind('Click', function() {
console.log("Clicked!!");
})
myEntity.bind('MouseUp', function(e) {
if( e.mouseButton == Crafty.mouseButtons.RIGHT )
console.log("Clicked right button");
})
public this .areaMap(Crafty.polygon polygon)
public this .areaMap(Array point1, .., Array pointN)
x
and y
position to generate a polygonAssign a polygon to the entity so that mouse events will only be triggered if the coordinates are inside the given polygon.
Crafty.e("2D, DOM, Color, Mouse")
.color("red")
.attr({ w: 100, h: 100 })
.bind('MouseOver', function() {console.log("over")})
.areaMap([0,0], [50,0], [50,50], [0,50])