Fix drumroll, pressed keys, pause menu, hide cursor

This commit is contained in:
LoveEevee
2018-09-18 16:59:40 +03:00
parent 0a62088d62
commit 772dac579f
8 changed files with 118 additions and 82 deletions

View File

@@ -2,8 +2,10 @@ class PageEvents{
constructor(){
this.allEvents = new Map()
this.keyListeners = new Map()
this.mouseListeners = new Map()
this.add(window, "keydown", this.keyEvent.bind(this))
this.add(window, "keyup", this.keyEvent.bind(this))
this.add(window, "mousemove", this.mouseEvent.bind(this))
}
add(target, type, callback){
this.remove(target, type)
@@ -112,4 +114,17 @@ class PageEvents{
})
})
}
mouseEvent(event){
this.lastMouse = event
this.mouseListeners.forEach(callback => callback(event))
}
mouseAdd(target, callback){
this.mouseListeners.set(target, callback)
}
mouseRemove(target){
this.mouseListeners.delete(target)
}
getMouse(){
return this.lastMouse
}
}