2013-08-08 18:16:47 +00:00
|
|
|
/// <reference path="../_definitions.ts" />
|
2013-05-14 02:37:38 +00:00
|
|
|
/**
|
|
|
|
* Phaser - MSPointer
|
|
|
|
*
|
2013-05-16 01:36:58 +00:00
|
|
|
* The MSPointer class handles touch interactions with the game and the resulting Pointer objects.
|
2013-08-28 06:02:55 +00:00
|
|
|
* It will work only in Internet Explorer 10 and Windows Store or Windows Phone 8 apps using JavaScript.
|
2013-05-14 02:37:38 +00:00
|
|
|
* http://msdn.microsoft.com/en-us/library/ie/hh673557(v=vs.85).aspx
|
|
|
|
*/
|
2013-08-28 06:02:55 +00:00
|
|
|
var Phaser;
|
|
|
|
(function (Phaser) {
|
|
|
|
var MSPointer = (function () {
|
|
|
|
/**
|
2013-05-14 02:37:38 +00:00
|
|
|
* Constructor
|
|
|
|
* @param {Game} game.
|
|
|
|
* @return {MSPointer} This object.
|
|
|
|
*/
|
2013-08-28 06:02:55 +00:00
|
|
|
function MSPointer(game) {
|
|
|
|
/**
|
|
|
|
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
|
|
|
|
* @type {bool}
|
|
|
|
*/
|
|
|
|
this.disabled = false;
|
2013-08-05 02:43:20 +00:00
|
|
|
this.game = game;
|
2013-05-14 02:37:38 +00:00
|
|
|
}
|
2013-08-28 06:02:55 +00:00
|
|
|
MSPointer.prototype.start = /**
|
2013-05-16 20:34:24 +00:00
|
|
|
* Starts the event listeners running
|
2013-08-28 06:02:55 +00:00
|
|
|
* @method start
|
2013-05-14 02:37:38 +00:00
|
|
|
*/
|
2013-08-28 06:02:55 +00:00
|
|
|
function () {
|
|
|
|
var _this = this;
|
|
|
|
if(this.game.device.mspointer == true) {
|
|
|
|
this._onMSPointerDown = function (event) {
|
|
|
|
return _this.onPointerDown(event);
|
|
|
|
};
|
|
|
|
this._onMSPointerMove = function (event) {
|
|
|
|
return _this.onPointerMove(event);
|
|
|
|
};
|
|
|
|
this._onMSPointerUp = function (event) {
|
|
|
|
return _this.onPointerUp(event);
|
|
|
|
};
|
2013-08-05 02:43:20 +00:00
|
|
|
this.game.stage.canvas.addEventListener('MSPointerDown', this._onMSPointerDown, false);
|
|
|
|
this.game.stage.canvas.addEventListener('MSPointerMove', this._onMSPointerMove, false);
|
|
|
|
this.game.stage.canvas.addEventListener('MSPointerUp', this._onMSPointerUp, false);
|
2013-05-14 02:37:38 +00:00
|
|
|
}
|
2013-08-28 06:02:55 +00:00
|
|
|
};
|
|
|
|
MSPointer.prototype.onPointerDown = /**
|
|
|
|
*
|
2013-05-14 02:37:38 +00:00
|
|
|
* @method onPointerDown
|
|
|
|
* @param {Any} event
|
|
|
|
**/
|
2013-08-28 06:02:55 +00:00
|
|
|
function (event) {
|
|
|
|
if(this.game.input.disabled || this.disabled) {
|
2013-05-16 01:36:58 +00:00
|
|
|
return;
|
2013-05-14 02:37:38 +00:00
|
|
|
}
|
2013-05-16 01:36:58 +00:00
|
|
|
event.preventDefault();
|
|
|
|
event.identifier = event.pointerId;
|
2013-08-05 02:43:20 +00:00
|
|
|
this.game.input.startPointer(event);
|
2013-08-28 06:02:55 +00:00
|
|
|
};
|
|
|
|
MSPointer.prototype.onPointerMove = /**
|
|
|
|
*
|
2013-05-14 02:37:38 +00:00
|
|
|
* @method onPointerMove
|
|
|
|
* @param {Any} event
|
|
|
|
**/
|
2013-08-28 06:02:55 +00:00
|
|
|
function (event) {
|
|
|
|
if(this.game.input.disabled || this.disabled) {
|
2013-05-16 01:36:58 +00:00
|
|
|
return;
|
2013-05-14 02:37:38 +00:00
|
|
|
}
|
2013-05-16 01:36:58 +00:00
|
|
|
event.preventDefault();
|
|
|
|
event.identifier = event.pointerId;
|
2013-08-05 02:43:20 +00:00
|
|
|
this.game.input.updatePointer(event);
|
2013-08-28 06:02:55 +00:00
|
|
|
};
|
|
|
|
MSPointer.prototype.onPointerUp = /**
|
|
|
|
*
|
2013-05-14 02:37:38 +00:00
|
|
|
* @method onPointerUp
|
|
|
|
* @param {Any} event
|
|
|
|
**/
|
2013-08-28 06:02:55 +00:00
|
|
|
function (event) {
|
|
|
|
if(this.game.input.disabled || this.disabled) {
|
2013-05-16 01:36:58 +00:00
|
|
|
return;
|
2013-05-14 02:37:38 +00:00
|
|
|
}
|
2013-05-16 01:36:58 +00:00
|
|
|
event.preventDefault();
|
|
|
|
event.identifier = event.pointerId;
|
2013-08-05 02:43:20 +00:00
|
|
|
this.game.input.stopPointer(event);
|
2013-08-28 06:02:55 +00:00
|
|
|
};
|
|
|
|
MSPointer.prototype.stop = /**
|
2013-05-16 20:34:24 +00:00
|
|
|
* Stop the event listeners
|
2013-08-28 06:02:55 +00:00
|
|
|
* @method stop
|
2013-05-14 02:37:38 +00:00
|
|
|
*/
|
2013-08-28 06:02:55 +00:00
|
|
|
function () {
|
|
|
|
if(this.game.device.mspointer == true) {
|
2013-08-05 02:43:20 +00:00
|
|
|
this.game.stage.canvas.removeEventListener('MSPointerDown', this._onMSPointerDown);
|
|
|
|
this.game.stage.canvas.removeEventListener('MSPointerMove', this._onMSPointerMove);
|
|
|
|
this.game.stage.canvas.removeEventListener('MSPointerUp', this._onMSPointerUp);
|
2013-05-16 20:34:24 +00:00
|
|
|
}
|
2013-08-28 06:02:55 +00:00
|
|
|
};
|
|
|
|
return MSPointer;
|
|
|
|
})();
|
|
|
|
Phaser.MSPointer = MSPointer;
|
|
|
|
})(Phaser || (Phaser = {}));
|