mirror of
https://github.com/wassname/phaser.git
synced 2026-09-12 12:40:47 +08:00
Lots of tweaks and fixes to the orientation and fullscreen classes
This commit is contained in:
+10
-10
@@ -513,17 +513,9 @@ module Phaser {
|
||||
if (this.pointer10) { this.pointer10.reset(); }
|
||||
|
||||
this.currentPointers = 0;
|
||||
|
||||
for (var i = 0; i < this.totalTrackedObjects; i++)
|
||||
{
|
||||
this.inputObjects[i].input.reset();
|
||||
}
|
||||
|
||||
|
||||
this._game.stage.canvas.style.cursor = "default";
|
||||
|
||||
this.inputObjects.length = 0;
|
||||
this.totalTrackedObjects = 0;
|
||||
|
||||
if (hard == true)
|
||||
{
|
||||
this.onDown.dispose();
|
||||
@@ -535,6 +527,14 @@ module Phaser {
|
||||
this.onUp = new Phaser.Signal();
|
||||
this.onTap = new Phaser.Signal();
|
||||
this.onHold = new Phaser.Signal();
|
||||
|
||||
for (var i = 0; i < this.totalTrackedObjects; i++)
|
||||
{
|
||||
this.inputObjects[i].input.reset();
|
||||
}
|
||||
|
||||
this.inputObjects.length = 0;
|
||||
this.totalTrackedObjects = 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -904,7 +904,7 @@ module Phaser {
|
||||
*/
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
this._game.stage.context.font = '14px Courier';
|
||||
this._game.stage.context.font = '24px Courier';
|
||||
this._game.stage.context.fillStyle = color;
|
||||
this._game.stage.context.fillText('Input', x, y);
|
||||
this._game.stage.context.fillText('Screen X: ' + this.x + ' Screen Y: ' + this.y, x, y + 14);
|
||||
|
||||
@@ -13,6 +13,7 @@ module Phaser {
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
this.callbackContext = this._game;
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +35,15 @@ module Phaser {
|
||||
*/
|
||||
public disabled: bool = false;
|
||||
|
||||
/**
|
||||
* Custom callback useful for hooking into a 3rd party library. Will be passed the mouse event as the only parameter.
|
||||
* Callbacks are fired even if this component is disabled and before the event propagation is disabled.
|
||||
*/
|
||||
public callbackContext;
|
||||
public mouseDownCallback = null;
|
||||
public mouseMoveCallback = null;
|
||||
public mouseUpCallback = null;
|
||||
|
||||
/**
|
||||
* Starts the event listeners running
|
||||
* @method start
|
||||
@@ -51,6 +61,11 @@ module Phaser {
|
||||
*/
|
||||
public onMouseDown(event: MouseEvent) {
|
||||
|
||||
if (this.mouseDownCallback)
|
||||
{
|
||||
this.mouseDownCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
if (this._game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
@@ -67,6 +82,11 @@ module Phaser {
|
||||
*/
|
||||
public onMouseMove(event: MouseEvent) {
|
||||
|
||||
if (this.mouseMoveCallback)
|
||||
{
|
||||
this.mouseMoveCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
if (this._game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
@@ -83,6 +103,11 @@ module Phaser {
|
||||
*/
|
||||
public onMouseUp(event: MouseEvent) {
|
||||
|
||||
if (this.mouseUpCallback)
|
||||
{
|
||||
this.mouseUpCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
if (this._game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
|
||||
+24
-4
@@ -282,6 +282,22 @@ module Phaser {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the X value of this Pointer in world coordinate space
|
||||
* @param {Camera} [camera]
|
||||
*/
|
||||
public get scaledX():number {
|
||||
return Math.floor(this.x * this.game.input.scaleX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Y value of this Pointer in world coordinate space
|
||||
* @param {Camera} [camera]
|
||||
*/
|
||||
public get scaledY():number {
|
||||
return Math.floor(this.y * this.game.input.scaleY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Pointer is pressed onto the touchscreen
|
||||
* @method start
|
||||
@@ -298,7 +314,7 @@ module Phaser {
|
||||
}
|
||||
|
||||
// Fix to stop rogue browser plugins from blocking the visibility state event
|
||||
if (this.game.paused == true)
|
||||
if (this.game.paused == true && this.game.stage.scale.incorrectOrientation == false)
|
||||
{
|
||||
this.game.stage.resumeGame();
|
||||
return this;
|
||||
@@ -495,11 +511,9 @@ module Phaser {
|
||||
}
|
||||
}
|
||||
|
||||
//console.log('pointer move', _highestRenderID);
|
||||
|
||||
if (_highestRenderObject !== -1)
|
||||
{
|
||||
console.log('setting target');
|
||||
//console.log('setting target');
|
||||
this.targetObject = this.game.input.inputObjects[_highestRenderObject];
|
||||
this.targetObject.input._pointerOverHandler(this);
|
||||
}
|
||||
@@ -650,6 +664,12 @@ module Phaser {
|
||||
this._holdSent = false;
|
||||
this._history.length = 0;
|
||||
this._stateReset = true;
|
||||
|
||||
if (this.targetObject)
|
||||
{
|
||||
this.targetObject.input._releasedHandler(this);
|
||||
}
|
||||
|
||||
this.targetObject = null;
|
||||
|
||||
}
|
||||
|
||||
+45
-2
@@ -23,6 +23,7 @@ module Phaser {
|
||||
constructor(game: Game) {
|
||||
|
||||
this._game = game;
|
||||
this.callbackContext = this._game;
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +41,18 @@ module Phaser {
|
||||
*/
|
||||
public disabled: bool = false;
|
||||
|
||||
/**
|
||||
* Custom callback useful for hooking into a 3rd party library. Will be passed the touch event as the only parameter.
|
||||
* Callbacks are fired even if this component is disabled and before the event propogation is disabled.
|
||||
*/
|
||||
public callbackContext;
|
||||
public touchStartCallback = null;
|
||||
public touchMoveCallback = null;
|
||||
public touchEndCallback = null;
|
||||
public touchEnterCallback = null;
|
||||
public touchLeaveCallback = null;
|
||||
public touchCancelCallback = null;
|
||||
|
||||
/**
|
||||
* Starts the event listeners running
|
||||
* @method start
|
||||
@@ -78,6 +91,11 @@ module Phaser {
|
||||
**/
|
||||
private onTouchStart(event) {
|
||||
|
||||
if (this.touchStartCallback)
|
||||
{
|
||||
this.touchStartCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
if (this._game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
@@ -103,6 +121,11 @@ module Phaser {
|
||||
**/
|
||||
private onTouchCancel(event) {
|
||||
|
||||
if (this.touchCancelCallback)
|
||||
{
|
||||
this.touchCancelCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
if (this._game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
@@ -127,6 +150,11 @@ module Phaser {
|
||||
**/
|
||||
private onTouchEnter(event) {
|
||||
|
||||
if (this.touchEnterCallback)
|
||||
{
|
||||
this.touchEnterCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
if (this._game.input.disabled || this.disabled)
|
||||
{
|
||||
return;
|
||||
@@ -136,7 +164,7 @@ module Phaser {
|
||||
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
console.log('touch enter');
|
||||
//console.log('touch enter');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -149,11 +177,16 @@ module Phaser {
|
||||
**/
|
||||
private onTouchLeave(event) {
|
||||
|
||||
if (this.touchLeaveCallback)
|
||||
{
|
||||
this.touchLeaveCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
{
|
||||
console.log('touch leave');
|
||||
//console.log('touch leave');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -165,6 +198,11 @@ module Phaser {
|
||||
**/
|
||||
private onTouchMove(event) {
|
||||
|
||||
if (this.touchMoveCallback)
|
||||
{
|
||||
this.touchMoveCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
for (var i = 0; i < event.changedTouches.length; i++)
|
||||
@@ -181,6 +219,11 @@ module Phaser {
|
||||
**/
|
||||
private onTouchEnd(event) {
|
||||
|
||||
if (this.touchEndCallback)
|
||||
{
|
||||
this.touchEndCallback.call(this.callbackContext, event);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// For touch end its a list of the touch points that have been removed from the surface
|
||||
|
||||
Reference in New Issue
Block a user