phaser/v3/src/input/Pointer.js

96 lines
1.7 KiB
JavaScript
Raw Normal View History

// Phaser.Input.Pointer
var Class = require('../utils/Class');
var Pointer = new Class({
initialize:
function Pointer (manager, id)
{
this.manager = manager;
this.id = id;
this.event;
this.button = 0;
this.x = 0;
this.y = 0;
this.isDown = false;
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;
this.justDown = false;
this.justUp = false;
this.justMoved = false;
},
move: function (event)
{
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);
this.justMoved = true;
2017-07-18 16:22:14 +00:00
this.dirty = true;
},
down: function (event)
{
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);
this.justDown = true;
2017-07-18 16:22:14 +00:00
this.isDown = true;
this.dirty = true;
},
up: function (event)
{
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);
this.justUp = true;
2017-07-18 16:22:14 +00:00
this.isDown = false;
this.dirty = true;
}
});
module.exports = Pointer;