mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
implemented mouse looking
This commit is contained in:
parent
88d70f2549
commit
5f7917c5cc
9 changed files with 117 additions and 19 deletions
38
app/Game/Client/Control/Input/MouseInput.js
Normal file
38
app/Game/Client/Control/Input/MouseInput.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
define([
|
||||
"Game/Client/Control/Input/XyInput",
|
||||
"Game/Client/View/DomController",
|
||||
"Game/Config/Settings"
|
||||
],
|
||||
|
||||
function (Parent, DomController, Settings) {
|
||||
|
||||
function MouseInput() {
|
||||
Parent.call(this);
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
MouseInput.prototype = Object.create(Parent.prototype);
|
||||
|
||||
MouseInput.prototype.init = function() {
|
||||
|
||||
var canvas = null;
|
||||
var self = this;
|
||||
canvas = DomController.getCanvas();
|
||||
|
||||
canvas.onmousemove = function(e){
|
||||
|
||||
// -1 +1 +1 +1 xy scaling should
|
||||
// -1 -1 +1 -1 be like this
|
||||
|
||||
var x = (((e.clientX - this.offsetLeft) / Settings.STAGE_WIDTH) * 2) - 1;
|
||||
var y = (((Settings.STAGE_HEIGHT - (e.clientY - this.offsetTop)) / Settings.STAGE_HEIGHT) * 2) -1;
|
||||
|
||||
self.onXyChange(x, y);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return MouseInput;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue