Muni
This commit is contained in:
parent
bc9b273481
commit
3dad07d3fa
16
objects.js
16
objects.js
@ -37,10 +37,10 @@ class Object {
|
||||
keyReleaseEvent(e) {
|
||||
|
||||
}
|
||||
mousePressEvent(e) {
|
||||
mousePressEvent(e,pressed) {
|
||||
|
||||
}
|
||||
mouseReleaseEvent(e) {
|
||||
mouseReleaseEvent(e,pressed) {
|
||||
|
||||
}
|
||||
mouseEvent(e) {
|
||||
@ -99,15 +99,15 @@ class DebugObj extends Object{
|
||||
this.storedMouseY=e.offsetY;
|
||||
//this.messages.push(this.lastMessage);
|
||||
}
|
||||
mousePressEvent(e) {
|
||||
mousePressEvent(e,pressed) {
|
||||
this.eventCount++;
|
||||
super.mousePressEvent(e);
|
||||
this.lastMessage="Mouse Press Event";
|
||||
super.mousePressEvent(e,pressed);
|
||||
this.lastMessage="Mouse Press Event: "+JSON.stringify(pressed);
|
||||
}
|
||||
mouseReleaseEvent(e) {
|
||||
mouseReleaseEvent(e,pressed) {
|
||||
this.eventCount++;
|
||||
super.mouseReleaseEvent(e);
|
||||
this.lastMessage="Mouse Release Event";
|
||||
super.mouseReleaseEvent(e,pressed);
|
||||
this.lastMessage="Mouse Release Event: "+JSON.stringify(pressed);
|
||||
}
|
||||
keyPressEvent(e) {
|
||||
this.eventCount++;
|
||||
|
26
test.js
26
test.js
@ -78,28 +78,30 @@ function mousePressEvent(e) {
|
||||
"MOUSE4"
|
||||
"MOUSE5"
|
||||
*/
|
||||
var pressedDown = {left:false,right:false,middle:false,mouse4:false,mouse5:false}
|
||||
mouseDown.splice(0,mouseDown.length);
|
||||
var buttonamt = e.buttons;
|
||||
if (buttonamt>=16) {buttonamt-=16;mouseDown.push("MOUSE5");}
|
||||
if (buttonamt>=8) {buttonamt-=8;mouseDown.push("MOUSE4");}
|
||||
if (buttonamt>=4) {buttonamt-=4;mouseDown.push("MIDDLE");}
|
||||
if (buttonamt>=2) {buttonamt-=2;mouseDown.push("RIGHT");}
|
||||
if (buttonamt>=1) {buttonamt-=1;mouseDown.push("LEFT");}
|
||||
if (buttonamt>=16) {buttonamt-=16;pressedDown.mouse5=true;mouseDown.push("MOUSE5");}
|
||||
if (buttonamt>=8) {buttonamt-=8;pressedDown.mouse4=true;mouseDown.push("MOUSE4");}
|
||||
if (buttonamt>=4) {buttonamt-=4;pressedDown.middle=true;mouseDown.push("MIDDLE");}
|
||||
if (buttonamt>=2) {buttonamt-=2;pressedDown.right=true;mouseDown.push("RIGHT");}
|
||||
if (buttonamt>=1) {buttonamt-=1;pressedDown.left=true;mouseDown.push("LEFT");}
|
||||
for (i=0;i<gameObjs.length;i++) {
|
||||
gameObjs[i].mousePressEvent(e);
|
||||
gameObjs[i].mousePressEvent(e,pressedDown);
|
||||
}
|
||||
}
|
||||
|
||||
function mouseReleaseEvent(e) {
|
||||
var pressedDown = {left:false,right:false,middle:false,mouse4:false,mouse5:false}
|
||||
mouseDown.splice(0,mouseDown.length);
|
||||
var buttonamt = e.buttons;
|
||||
if (buttonamt>=16) {buttonamt-=16;mouseDown.push("MOUSE5");}
|
||||
if (buttonamt>=8) {buttonamt-=8;mouseDown.push("MOUSE4");}
|
||||
if (buttonamt>=4) {buttonamt-=4;mouseDown.push("MIDDLE");}
|
||||
if (buttonamt>=2) {buttonamt-=2;mouseDown.push("RIGHT");}
|
||||
if (buttonamt>=1) {buttonamt-=1;mouseDown.push("LEFT");}
|
||||
if (buttonamt>=16) {buttonamt-=16;pressedDown.mouse5=true;mouseDown.push("MOUSE5");}
|
||||
if (buttonamt>=8) {buttonamt-=8;pressedDown.mouse4=true;mouseDown.push("MOUSE4");}
|
||||
if (buttonamt>=4) {buttonamt-=4;pressedDown.middle=true;mouseDown.push("MIDDLE");}
|
||||
if (buttonamt>=2) {buttonamt-=2;pressedDown.right=true;mouseDown.push("RIGHT");}
|
||||
if (buttonamt>=1) {buttonamt-=1;pressedDown.left=true;mouseDown.push("LEFT");}
|
||||
for (i=0;i<gameObjs.length;i++) {
|
||||
gameObjs[i].mouseReleaseEvent(e);
|
||||
gameObjs[i].mouseReleaseEvent(e,pressedDown);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user