src/input/mouse.js in entityjs-0.4.1 vs src/input/mouse.js in entityjs-0.4.2
- old
+ new
@@ -45,11 +45,11 @@
//register mouse action
if(re.pressed.d){
re.pressed.d[c] = (e.type == 'mousedown');
}
- re.c('mouse').event(e, c);
+ re.mouse.event(e, c);
},
event:function(e, extra){
@@ -66,29 +66,32 @@
x *= e.layerX - canvas.offsetLeft;
y *= e.layerY - canvas.offsetTop;
}
- var listeners = re.c('mouse').l;
+ var listeners = re.mouse.l;
/*
if(re.preventDefault && re.preventDefault.d[key]){
e.preventDefault();
}
*/
- var c, t, obj;
+ var c, t, obj, tx, ty;
for(var i=0; i<listeners.length; i++){
t = listeners[i];
if(t.screenable){
- x = re.screen.toScreenX(x);
- y = re.screen.toScreenY(y);
+ tx = re.screen.toScreenX(x);
+ ty = re.screen.toScreenY(y);
+ } else {
+ tx = x;
+ ty = y;
}
//offset mouse coordinates
- var tx = x + t.offX;
- var ty = y + t.offY;
+ tx += t.offX;
+ ty += t.offY;
t.trigger(e.type, tx, ty, e);
if(extra){
t.trigger(e.type+':'+extra, tx, ty, e);
@@ -100,24 +103,26 @@
i:function(){
var c = re.sys.canvas;
re.listener('mousedown', this.press, c);
re.listener('mouseup', this.press, c);
re.listener('mousemove', this.event, c);
+ re.listener('mouseover', this.event, c);
+ re.listener('mouseout', this.event, c);
re.listener('click', this.event, c);
re.listener('dblclick', this.event, c);
re.listener('contextmenu', this.event, c);
}
})
.defaults({
offX:0,
offY:0
})
-.init(function(c){
+.init(function(){
//add to listener array
- c.l.push(this);
+ re.mouse.l.push(this);
})
-.dispose(function(c){
+.dispose(function(){
//remove from listener array
- c.l.splice(c.l.indexOf(this), 1);
+ re.mouse.l.splice(re.mouse.l.indexOf(this), 1);
});
\ No newline at end of file