2013-05-28 20:38:37 +00:00
|
|
|
/// <reference path="../Game.ts" />
|
2013-05-16 01:36:58 +00:00
|
|
|
/// <reference path="Pointer.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-05-14 02:37:38 +00:00
|
|
|
* It will work only in Internet Explorer 10 and Windows Store or Windows Phone 8 apps using JavaScript.
|
|
|
|
* http://msdn.microsoft.com/en-us/library/ie/hh673557(v=vs.85).aspx
|
|
|
|
*/
|
|
|
|
|
|
|
|
module Phaser {
|
|
|
|
|
|
|
|
export class MSPointer {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
* @param {Game} game.
|
|
|
|
* @return {MSPointer} This object.
|
|
|
|
*/
|
|
|
|
constructor(game: Game) {
|
|
|
|
|
|
|
|
this._game = game;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-05-16 20:34:24 +00:00
|
|
|
* Local private reference to game.
|
2013-05-14 02:37:38 +00:00
|
|
|
* @property _game
|
|
|
|
* @type Game
|
|
|
|
* @private
|
|
|
|
**/
|
|
|
|
private _game: Game;
|
|
|
|
|
2013-05-16 01:36:58 +00:00
|
|
|
/**
|
|
|
|
* You can disable all Input by setting disabled = true. While set all new input related events will be ignored.
|
|
|
|
* @type {Boolean}
|
|
|
|
*/
|
|
|
|
public disabled: bool = false;
|
2013-05-14 02:37:38 +00:00
|
|
|
|
|
|
|
/**
|
2013-05-16 20:34:24 +00:00
|
|
|
* Starts the event listeners running
|
2013-05-14 02:37:38 +00:00
|
|
|
* @method start
|
|
|
|
*/
|
|
|
|
public start() {
|
|
|
|
|
2013-05-16 01:36:58 +00:00
|
|
|
if (this._game.device.mspointer == true)
|
2013-05-14 02:37:38 +00:00
|
|
|
{
|
|
|
|
this._game.stage.canvas.addEventListener('MSPointerDown', (event) => this.onPointerDown(event), false);
|
|
|
|
this._game.stage.canvas.addEventListener('MSPointerMove', (event) => this.onPointerMove(event), false);
|
|
|
|
this._game.stage.canvas.addEventListener('MSPointerUp', (event) => this.onPointerUp(event), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @method onPointerDown
|
|
|
|
* @param {Any} event
|
|
|
|
**/
|
|
|
|
private onPointerDown(event) {
|
|
|
|
|
2013-05-16 01:36:58 +00:00
|
|
|
if (this._game.input.disabled || this.disabled)
|
2013-05-14 02:37:38 +00:00
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
this._game.input.startPointer(event);
|
|
|
|
|
2013-05-14 02:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @method onPointerMove
|
|
|
|
* @param {Any} event
|
|
|
|
**/
|
|
|
|
private onPointerMove(event) {
|
|
|
|
|
2013-05-16 01:36:58 +00:00
|
|
|
if (this._game.input.disabled || this.disabled)
|
2013-05-14 02:37:38 +00:00
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
this._game.input.updatePointer(event);
|
|
|
|
|
2013-05-14 02:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @method onPointerUp
|
|
|
|
* @param {Any} event
|
|
|
|
**/
|
|
|
|
private onPointerUp(event) {
|
|
|
|
|
2013-05-16 01:36:58 +00:00
|
|
|
if (this._game.input.disabled || this.disabled)
|
2013-05-14 02:37:38 +00:00
|
|
|
{
|
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-05-14 02:37:38 +00:00
|
|
|
|
2013-05-16 01:36:58 +00:00
|
|
|
this._game.input.stopPointer(event);
|
2013-05-14 02:37:38 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-05-16 20:34:24 +00:00
|
|
|
* Stop the event listeners
|
2013-05-14 02:37:38 +00:00
|
|
|
* @method stop
|
|
|
|
*/
|
|
|
|
public stop() {
|
|
|
|
|
2013-05-16 20:34:24 +00:00
|
|
|
if (this._game.device.mspointer == true)
|
|
|
|
{
|
|
|
|
//this._game.stage.canvas.addEventListener('MSPointerDown', (event) => this.onPointerDown(event), false);
|
|
|
|
//this._game.stage.canvas.addEventListener('MSPointerMove', (event) => this.onPointerMove(event), false);
|
|
|
|
//this._game.stage.canvas.addEventListener('MSPointerUp', (event) => this.onPointerUp(event), false);
|
|
|
|
}
|
|
|
|
|
2013-05-14 02:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|