DebugUtils converted, re-name spaced the Input classes and started on Camera culling.

This commit is contained in:
Richard Davey
2013-08-31 21:50:34 +01:00
parent 70ee753859
commit 22847f6ade
17 changed files with 1736 additions and 359 deletions
+14 -14
View File
@@ -13,9 +13,9 @@ Phaser.Input = function (game) {
};
Phaser.Input.MOUSE_OVERRIDES_TOUCH = 0;
Phaser.Input.TOUCH_OVERRIDES_MOUSE = 1;
Phaser.Input.MOUSE_TOUCH_COMBINE = 2;
Phaser.Mouse_OVERRIDES_TOUCH = 0;
Phaser.Touch_OVERRIDES_MOUSE = 1;
Phaser.Mouse_TOUCH_COMBINE = 2;
Phaser.Input.prototype = {
@@ -60,7 +60,7 @@ Phaser.Input.prototype = {
/**
* Controls the expected behaviour when using a mouse and touch together on a multi-input device
*/
multiInputOverride: Phaser.Input.MOUSE_TOUCH_COMBINE,
multiInputOverride: Phaser.Mouse_TOUCH_COMBINE,
/**
* A vector object representing the current position of the Pointer.
@@ -259,14 +259,14 @@ Phaser.Input.prototype = {
**/
boot: function () {
this.mousePointer = new Phaser.Input.Pointer(this.game, 0);
this.pointer1 = new Phaser.Input.Pointer(this.game, 1);
this.pointer2 = new Phaser.Input.Pointer(this.game, 2);
this.mousePointer = new Phaser.Pointer(this.game, 0);
this.pointer1 = new Phaser.Pointer(this.game, 1);
this.pointer2 = new Phaser.Pointer(this.game, 2);
this.mouse = new Phaser.Input.Mouse(this.game);
this.keyboard = new Phaser.Input.Keyboard(this.game);
this.touch = new Phaser.Input.Touch(this.game);
this.mspointer = new Phaser.Input.MSPointer(this.game);
this.mouse = new Phaser.Mouse(this.game);
this.keyboard = new Phaser.Keyboard(this.game);
this.touch = new Phaser.Touch(this.game);
this.mspointer = new Phaser.MSPointer(this.game);
this.onDown = new Phaser.Signal();
this.onUp = new Phaser.Signal();
@@ -321,7 +321,7 @@ Phaser.Input.prototype = {
}
else
{
this['pointer' + next] = new Phaser.Input.Pointer(this.game, next);
this['pointer' + next] = new Phaser.Pointer(this.game, next);
return this['pointer' + next];
}
@@ -700,7 +700,7 @@ Object.defineProperty(Phaser.Input.prototype, "totalActivePointers", {
Object.defineProperty(Phaser.Input.prototype, "worldX", {
get: function () {
return this.camera.worldView.x + this.x;
return this.game.camera.view.x + this.x;
},
enumerable: true,
@@ -710,7 +710,7 @@ Object.defineProperty(Phaser.Input.prototype, "worldX", {
Object.defineProperty(Phaser.Input.prototype, "worldY", {
get: function () {
return this.camera.worldView.x + this.x;
return this.game.camera.view.y + this.y;
},
enumerable: true,
+100 -100
View File
@@ -1,4 +1,4 @@
Phaser.Input.Keyboard = function (game) {
Phaser.Keyboard = function (game) {
this.game = game;
this._keys = {};
@@ -6,7 +6,7 @@ Phaser.Input.Keyboard = function (game) {
};
Phaser.Input.Keyboard.prototype = {
Phaser.Keyboard.prototype = {
game: null,
@@ -206,101 +206,101 @@ Phaser.Input.Keyboard.prototype = {
// Statics
Phaser.Input.Keyboard.A = "A".charCodeAt(0);
Phaser.Input.Keyboard.B = "B".charCodeAt(0);
Phaser.Input.Keyboard.C = "C".charCodeAt(0);
Phaser.Input.Keyboard.D = "D".charCodeAt(0);
Phaser.Input.Keyboard.E = "E".charCodeAt(0);
Phaser.Input.Keyboard.F = "F".charCodeAt(0);
Phaser.Input.Keyboard.G = "G".charCodeAt(0);
Phaser.Input.Keyboard.H = "H".charCodeAt(0);
Phaser.Input.Keyboard.I = "I".charCodeAt(0);
Phaser.Input.Keyboard.J = "J".charCodeAt(0);
Phaser.Input.Keyboard.K = "K".charCodeAt(0);
Phaser.Input.Keyboard.L = "L".charCodeAt(0);
Phaser.Input.Keyboard.M = "M".charCodeAt(0);
Phaser.Input.Keyboard.N = "N".charCodeAt(0);
Phaser.Input.Keyboard.O = "O".charCodeAt(0);
Phaser.Input.Keyboard.P = "P".charCodeAt(0);
Phaser.Input.Keyboard.Q = "Q".charCodeAt(0);
Phaser.Input.Keyboard.R = "R".charCodeAt(0);
Phaser.Input.Keyboard.S = "S".charCodeAt(0);
Phaser.Input.Keyboard.T = "T".charCodeAt(0);
Phaser.Input.Keyboard.U = "U".charCodeAt(0);
Phaser.Input.Keyboard.V = "V".charCodeAt(0);
Phaser.Input.Keyboard.W = "W".charCodeAt(0);
Phaser.Input.Keyboard.X = "X".charCodeAt(0);
Phaser.Input.Keyboard.Y = "Y".charCodeAt(0);
Phaser.Input.Keyboard.Z = "Z".charCodeAt(0);
Phaser.Input.Keyboard.ZERO = "0".charCodeAt(0);
Phaser.Input.Keyboard.ONE = "1".charCodeAt(0);
Phaser.Input.Keyboard.TWO = "2".charCodeAt(0);
Phaser.Input.Keyboard.THREE = "3".charCodeAt(0);
Phaser.Input.Keyboard.FOUR = "4".charCodeAt(0);
Phaser.Input.Keyboard.FIVE = "5".charCodeAt(0);
Phaser.Input.Keyboard.SIX = "6".charCodeAt(0);
Phaser.Input.Keyboard.SEVEN = "7".charCodeAt(0);
Phaser.Input.Keyboard.EIGHT = "8".charCodeAt(0);
Phaser.Input.Keyboard.NINE = "9".charCodeAt(0);
Phaser.Input.Keyboard.NUMPAD_0 = 96;
Phaser.Input.Keyboard.NUMPAD_1 = 97;
Phaser.Input.Keyboard.NUMPAD_2 = 98;
Phaser.Input.Keyboard.NUMPAD_3 = 99;
Phaser.Input.Keyboard.NUMPAD_4 = 100;
Phaser.Input.Keyboard.NUMPAD_5 = 101;
Phaser.Input.Keyboard.NUMPAD_6 = 102;
Phaser.Input.Keyboard.NUMPAD_7 = 103;
Phaser.Input.Keyboard.NUMPAD_8 = 104;
Phaser.Input.Keyboard.NUMPAD_9 = 105;
Phaser.Input.Keyboard.NUMPAD_MULTIPLY = 106;
Phaser.Input.Keyboard.NUMPAD_ADD = 107;
Phaser.Input.Keyboard.NUMPAD_ENTER = 108;
Phaser.Input.Keyboard.NUMPAD_SUBTRACT = 109;
Phaser.Input.Keyboard.NUMPAD_DECIMAL = 110;
Phaser.Input.Keyboard.NUMPAD_DIVIDE = 111;
Phaser.Input.Keyboard.F1 = 112;
Phaser.Input.Keyboard.F2 = 113;
Phaser.Input.Keyboard.F3 = 114;
Phaser.Input.Keyboard.F4 = 115;
Phaser.Input.Keyboard.F5 = 116;
Phaser.Input.Keyboard.F6 = 117;
Phaser.Input.Keyboard.F7 = 118;
Phaser.Input.Keyboard.F8 = 119;
Phaser.Input.Keyboard.F9 = 120;
Phaser.Input.Keyboard.F10 = 121;
Phaser.Input.Keyboard.F11 = 122;
Phaser.Input.Keyboard.F12 = 123;
Phaser.Input.Keyboard.F13 = 124;
Phaser.Input.Keyboard.F14 = 125;
Phaser.Input.Keyboard.F15 = 126;
Phaser.Input.Keyboard.COLON = 186;
Phaser.Input.Keyboard.EQUALS = 187;
Phaser.Input.Keyboard.UNDERSCORE = 189;
Phaser.Input.Keyboard.QUESTION_MARK = 191;
Phaser.Input.Keyboard.TILDE = 192;
Phaser.Input.Keyboard.OPEN_BRACKET = 219;
Phaser.Input.Keyboard.BACKWARD_SLASH = 220;
Phaser.Input.Keyboard.CLOSED_BRACKET = 221;
Phaser.Input.Keyboard.QUOTES = 222;
Phaser.Input.Keyboard.BACKSPACE = 8;
Phaser.Input.Keyboard.TAB = 9;
Phaser.Input.Keyboard.CLEAR = 12;
Phaser.Input.Keyboard.ENTER = 13;
Phaser.Input.Keyboard.SHIFT = 16;
Phaser.Input.Keyboard.CONTROL = 17;
Phaser.Input.Keyboard.ALT = 18;
Phaser.Input.Keyboard.CAPS_LOCK = 20;
Phaser.Input.Keyboard.ESC = 27;
Phaser.Input.Keyboard.SPACEBAR = 32;
Phaser.Input.Keyboard.PAGE_UP = 33;
Phaser.Input.Keyboard.PAGE_DOWN = 34;
Phaser.Input.Keyboard.END = 35;
Phaser.Input.Keyboard.HOME = 36;
Phaser.Input.Keyboard.LEFT = 37;
Phaser.Input.Keyboard.UP = 38;
Phaser.Input.Keyboard.RIGHT = 39;
Phaser.Input.Keyboard.DOWN = 40;
Phaser.Input.Keyboard.INSERT = 45;
Phaser.Input.Keyboard.DELETE = 46;
Phaser.Input.Keyboard.HELP = 47;
Phaser.Input.Keyboard.NUM_LOCK = 144;
Phaser.Keyboard.A = "A".charCodeAt(0);
Phaser.Keyboard.B = "B".charCodeAt(0);
Phaser.Keyboard.C = "C".charCodeAt(0);
Phaser.Keyboard.D = "D".charCodeAt(0);
Phaser.Keyboard.E = "E".charCodeAt(0);
Phaser.Keyboard.F = "F".charCodeAt(0);
Phaser.Keyboard.G = "G".charCodeAt(0);
Phaser.Keyboard.H = "H".charCodeAt(0);
Phaser.Keyboard.I = "I".charCodeAt(0);
Phaser.Keyboard.J = "J".charCodeAt(0);
Phaser.Keyboard.K = "K".charCodeAt(0);
Phaser.Keyboard.L = "L".charCodeAt(0);
Phaser.Keyboard.M = "M".charCodeAt(0);
Phaser.Keyboard.N = "N".charCodeAt(0);
Phaser.Keyboard.O = "O".charCodeAt(0);
Phaser.Keyboard.P = "P".charCodeAt(0);
Phaser.Keyboard.Q = "Q".charCodeAt(0);
Phaser.Keyboard.R = "R".charCodeAt(0);
Phaser.Keyboard.S = "S".charCodeAt(0);
Phaser.Keyboard.T = "T".charCodeAt(0);
Phaser.Keyboard.U = "U".charCodeAt(0);
Phaser.Keyboard.V = "V".charCodeAt(0);
Phaser.Keyboard.W = "W".charCodeAt(0);
Phaser.Keyboard.X = "X".charCodeAt(0);
Phaser.Keyboard.Y = "Y".charCodeAt(0);
Phaser.Keyboard.Z = "Z".charCodeAt(0);
Phaser.Keyboard.ZERO = "0".charCodeAt(0);
Phaser.Keyboard.ONE = "1".charCodeAt(0);
Phaser.Keyboard.TWO = "2".charCodeAt(0);
Phaser.Keyboard.THREE = "3".charCodeAt(0);
Phaser.Keyboard.FOUR = "4".charCodeAt(0);
Phaser.Keyboard.FIVE = "5".charCodeAt(0);
Phaser.Keyboard.SIX = "6".charCodeAt(0);
Phaser.Keyboard.SEVEN = "7".charCodeAt(0);
Phaser.Keyboard.EIGHT = "8".charCodeAt(0);
Phaser.Keyboard.NINE = "9".charCodeAt(0);
Phaser.Keyboard.NUMPAD_0 = 96;
Phaser.Keyboard.NUMPAD_1 = 97;
Phaser.Keyboard.NUMPAD_2 = 98;
Phaser.Keyboard.NUMPAD_3 = 99;
Phaser.Keyboard.NUMPAD_4 = 100;
Phaser.Keyboard.NUMPAD_5 = 101;
Phaser.Keyboard.NUMPAD_6 = 102;
Phaser.Keyboard.NUMPAD_7 = 103;
Phaser.Keyboard.NUMPAD_8 = 104;
Phaser.Keyboard.NUMPAD_9 = 105;
Phaser.Keyboard.NUMPAD_MULTIPLY = 106;
Phaser.Keyboard.NUMPAD_ADD = 107;
Phaser.Keyboard.NUMPAD_ENTER = 108;
Phaser.Keyboard.NUMPAD_SUBTRACT = 109;
Phaser.Keyboard.NUMPAD_DECIMAL = 110;
Phaser.Keyboard.NUMPAD_DIVIDE = 111;
Phaser.Keyboard.F1 = 112;
Phaser.Keyboard.F2 = 113;
Phaser.Keyboard.F3 = 114;
Phaser.Keyboard.F4 = 115;
Phaser.Keyboard.F5 = 116;
Phaser.Keyboard.F6 = 117;
Phaser.Keyboard.F7 = 118;
Phaser.Keyboard.F8 = 119;
Phaser.Keyboard.F9 = 120;
Phaser.Keyboard.F10 = 121;
Phaser.Keyboard.F11 = 122;
Phaser.Keyboard.F12 = 123;
Phaser.Keyboard.F13 = 124;
Phaser.Keyboard.F14 = 125;
Phaser.Keyboard.F15 = 126;
Phaser.Keyboard.COLON = 186;
Phaser.Keyboard.EQUALS = 187;
Phaser.Keyboard.UNDERSCORE = 189;
Phaser.Keyboard.QUESTION_MARK = 191;
Phaser.Keyboard.TILDE = 192;
Phaser.Keyboard.OPEN_BRACKET = 219;
Phaser.Keyboard.BACKWARD_SLASH = 220;
Phaser.Keyboard.CLOSED_BRACKET = 221;
Phaser.Keyboard.QUOTES = 222;
Phaser.Keyboard.BACKSPACE = 8;
Phaser.Keyboard.TAB = 9;
Phaser.Keyboard.CLEAR = 12;
Phaser.Keyboard.ENTER = 13;
Phaser.Keyboard.SHIFT = 16;
Phaser.Keyboard.CONTROL = 17;
Phaser.Keyboard.ALT = 18;
Phaser.Keyboard.CAPS_LOCK = 20;
Phaser.Keyboard.ESC = 27;
Phaser.Keyboard.SPACEBAR = 32;
Phaser.Keyboard.PAGE_UP = 33;
Phaser.Keyboard.PAGE_DOWN = 34;
Phaser.Keyboard.END = 35;
Phaser.Keyboard.HOME = 36;
Phaser.Keyboard.LEFT = 37;
Phaser.Keyboard.UP = 38;
Phaser.Keyboard.RIGHT = 39;
Phaser.Keyboard.DOWN = 40;
Phaser.Keyboard.INSERT = 45;
Phaser.Keyboard.DELETE = 46;
Phaser.Keyboard.HELP = 47;
Phaser.Keyboard.NUM_LOCK = 144;
+7 -3
View File
@@ -1,11 +1,11 @@
/**
* Phaser.Input.MSPointer
* Phaser.MSPointer
*
* The MSPointer class handles touch interactions with the game and the resulting Pointer objects.
* 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
*/
Phaser.Input.MSPointer = function (game) {
Phaser.MSPointer = function (game) {
this.game = game;
this.callbackContext = this.game;
@@ -16,7 +16,7 @@ Phaser.Input.MSPointer = function (game) {
};
Phaser.Input.MSPointer.prototype = {
Phaser.MSPointer.prototype = {
game: null,
@@ -55,6 +55,10 @@ Phaser.Input.MSPointer.prototype = {
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);
this.game.stage.canvas.style['-ms-content-zooming'] = 'none';
this.game.stage.canvas.style['-ms-touch-action'] = 'none';
}
},
+5 -5
View File
@@ -1,4 +1,4 @@
Phaser.Input.Mouse = function (game) {
Phaser.Mouse = function (game) {
this.game = game;
this.callbackContext = this.game;
@@ -9,11 +9,11 @@ Phaser.Input.Mouse = function (game) {
};
Phaser.Input.Mouse.LEFT_BUTTON = 0;
Phaser.Input.Mouse.MIDDLE_BUTTON = 1;
Phaser.Input.Mouse.RIGHT_BUTTON = 2;
Phaser.Mouse.LEFT_BUTTON = 0;
Phaser.Mouse.MIDDLE_BUTTON = 1;
Phaser.Mouse.RIGHT_BUTTON = 2;
Phaser.Input.Mouse.prototype = {
Phaser.Mouse.prototype = {
game: null,
+9 -9
View File
@@ -3,7 +3,7 @@
*
* A Pointer object is used by the Mouse, Touch and MSPoint managers and represents a single finger on the touch screen.
*/
Phaser.Input.Pointer = function (game, id) {
Phaser.Pointer = function (game, id) {
this.game = game;
this.id = id;
@@ -22,7 +22,7 @@ Phaser.Input.Pointer = function (game, id) {
};
Phaser.Input.Pointer.prototype = {
Phaser.Pointer.prototype = {
/**
* Local private variable to store the status of dispatching a hold event
@@ -238,7 +238,7 @@ Phaser.Input.Pointer.prototype = {
// x and y are the old values here?
this.positionDown.setTo(this.x, this.y);
if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
if (this.game.input.multiInputOverride == Phaser.Mouse_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Mouse_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Touch_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
{
//this.game.input.x = this.x * this.game.input.scale.x;
//this.game.input.y = this.y * this.game.input.scale.y;
@@ -272,7 +272,7 @@ Phaser.Input.Pointer.prototype = {
{
if (this._holdSent == false && this.duration >= this.game.input.holdRate)
{
if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
if (this.game.input.multiInputOverride == Phaser.Mouse_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Mouse_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Touch_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
{
this.game.input.onHold.dispatch(this);
}
@@ -335,7 +335,7 @@ Phaser.Input.Pointer.prototype = {
this.circle.x = this.x;
this.circle.y = this.y;
if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
if (this.game.input.multiInputOverride == Phaser.Mouse_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Mouse_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Touch_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
{
this.game.input.activePointer = this;
this.game.input.x = this.x;
@@ -453,7 +453,7 @@ Phaser.Input.Pointer.prototype = {
this.timeUp = this.game.time.now;
if (this.game.input.multiInputOverride == Phaser.Input.MOUSE_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Input.MOUSE_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Input.TOUCH_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
if (this.game.input.multiInputOverride == Phaser.Mouse_OVERRIDES_TOUCH || this.game.input.multiInputOverride == Phaser.Mouse_TOUCH_COMBINE || (this.game.input.multiInputOverride == Phaser.Touch_OVERRIDES_MOUSE && this.game.input.currentPointers == 0))
{
this.game.input.onUp.dispatch(this);
@@ -576,7 +576,7 @@ Phaser.Input.Pointer.prototype = {
};
Object.defineProperty(Phaser.Input.Pointer.prototype, "duration", {
Object.defineProperty(Phaser.Pointer.prototype, "duration", {
/**
* How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
@@ -598,7 +598,7 @@ Object.defineProperty(Phaser.Input.Pointer.prototype, "duration", {
configurable: true
});
Object.defineProperty(Phaser.Input.Pointer.prototype, "worldX", {
Object.defineProperty(Phaser.Pointer.prototype, "worldX", {
/**
* Gets the X value of this Pointer in world coordinates based on the given camera.
@@ -614,7 +614,7 @@ Object.defineProperty(Phaser.Input.Pointer.prototype, "worldX", {
configurable: true
});
Object.defineProperty(Phaser.Input.Pointer.prototype, "worldY", {
Object.defineProperty(Phaser.Pointer.prototype, "worldY", {
/**
* Gets the Y value of this Pointer in world coordinates based on the given camera.
+2 -2
View File
@@ -7,7 +7,7 @@
* http://www.html5rocks.com/en/mobile/touchandmouse/
* Note: Android 2.x only supports 1 touch event at once, no multi-touch
*/
Phaser.Input.Touch = function (game) {
Phaser.Touch = function (game) {
this.game = game;
this.callbackContext = this.game;
@@ -21,7 +21,7 @@ Phaser.Input.Touch = function (game) {
};
Phaser.Input.Touch.prototype = {
Phaser.Touch.prototype = {
game: null,