2017-07-13 16:21:37 +00:00
|
|
|
// Phaser.Input.Pointer
|
|
|
|
|
|
|
|
var Class = require('../utils/Class');
|
|
|
|
|
|
|
|
var Pointer = new Class({
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
2017-07-21 02:39:55 +00:00
|
|
|
function Pointer (manager, id)
|
2017-07-13 16:21:37 +00:00
|
|
|
{
|
|
|
|
this.manager = manager;
|
|
|
|
|
2017-07-21 02:39:55 +00:00
|
|
|
this.id = id;
|
|
|
|
|
2017-07-18 01:36:45 +00:00
|
|
|
this.event;
|
|
|
|
|
2017-07-17 22:38:43 +00:00
|
|
|
this.button = 0;
|
|
|
|
|
2017-07-13 16:21:37 +00:00
|
|
|
this.x = 0;
|
|
|
|
this.y = 0;
|
|
|
|
|
|
|
|
this.isDown = false;
|
2017-07-14 00:38:21 +00:00
|
|
|
|
|
|
|
this.dirty = false;
|
|
|
|
|
|
|
|
this.justDown = false;
|
|
|
|
this.justUp = false;
|
|
|
|
this.justMoved = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
reset: function ()
|
|
|
|
{
|
|
|
|
this.dirty = false;
|
2017-07-18 16:22:14 +00:00
|
|
|
this.isDown = false;
|
2017-07-14 00:38:21 +00:00
|
|
|
this.justDown = false;
|
|
|
|
this.justUp = false;
|
|
|
|
this.justMoved = false;
|
2017-07-13 16:21:37 +00:00
|
|
|
},
|
|
|
|
|
2017-07-14 00:38:21 +00:00
|
|
|
move: function (event)
|
2017-07-13 16:21:37 +00:00
|
|
|
{
|
2017-07-17 22:38:43 +00:00
|
|
|
if (event.button !== undefined)
|
|
|
|
{
|
|
|
|
this.button = event.button;
|
|
|
|
}
|
2017-07-14 00:38:21 +00:00
|
|
|
|
2017-07-18 01:36:45 +00:00
|
|
|
this.event = event;
|
2017-07-14 00:38:21 +00:00
|
|
|
|
2017-07-17 22:38:43 +00:00
|
|
|
this.x = this.manager.transformX(event.pageX);
|
|
|
|
this.y = this.manager.transformY(event.pageY);
|
|
|
|
|
2017-07-14 00:38:21 +00:00
|
|
|
this.justMoved = true;
|
2017-07-18 16:22:14 +00:00
|
|
|
|
|
|
|
this.dirty = true;
|
2017-07-14 00:38:21 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
down: function (event)
|
|
|
|
{
|
2017-07-18 01:36:45 +00:00
|
|
|
if (event.button !== undefined)
|
|
|
|
{
|
|
|
|
this.button = event.button;
|
|
|
|
}
|
2017-07-14 00:38:21 +00:00
|
|
|
|
2017-07-18 01:36:45 +00:00
|
|
|
this.event = event;
|
|
|
|
|
|
|
|
this.x = this.manager.transformX(event.pageX);
|
|
|
|
this.y = this.manager.transformY(event.pageY);
|
|
|
|
|
2017-07-14 00:38:21 +00:00
|
|
|
this.justDown = true;
|
2017-07-18 16:22:14 +00:00
|
|
|
this.isDown = true;
|
|
|
|
|
|
|
|
this.dirty = true;
|
2017-07-14 00:38:21 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
up: function (event)
|
|
|
|
{
|
2017-07-18 01:36:45 +00:00
|
|
|
if (event.button !== undefined)
|
|
|
|
{
|
|
|
|
this.button = event.button;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.event = event;
|
|
|
|
|
|
|
|
this.x = this.manager.transformX(event.pageX);
|
|
|
|
this.y = this.manager.transformY(event.pageY);
|
2017-07-14 00:38:21 +00:00
|
|
|
|
|
|
|
this.justUp = true;
|
2017-07-18 16:22:14 +00:00
|
|
|
this.isDown = false;
|
|
|
|
|
|
|
|
this.dirty = true;
|
2017-07-13 16:21:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = Pointer;
|