diff --git a/Phaser/Game.ts b/Phaser/Game.ts
index 3d92a6d1..76bdea63 100644
--- a/Phaser/Game.ts
+++ b/Phaser/Game.ts
@@ -25,6 +25,7 @@
///
///
///
+///
/**
* Phaser - Game
@@ -303,6 +304,7 @@ module Phaser {
this.isBooted = true;
// Set-up some static helper references
+ DebugUtils.game = this;
ColorUtils.game = this;
// Display the default game screen?
diff --git a/Phaser/Phaser.csproj b/Phaser/Phaser.csproj
index 4076c036..8238d8c1 100644
--- a/Phaser/Phaser.csproj
+++ b/Phaser/Phaser.csproj
@@ -178,6 +178,10 @@
ColorUtils.ts
+
+
+ DebugUtils.ts
+
PixelUtils.ts
diff --git a/Phaser/cameras/Camera.ts b/Phaser/cameras/Camera.ts
index aee5cbc4..6d997fef 100644
--- a/Phaser/cameras/Camera.ts
+++ b/Phaser/cameras/Camera.ts
@@ -474,11 +474,6 @@ module Phaser {
this._game.stage.context.globalAlpha = 1;
}
- // Debug test
- this._game.stage.context.fillStyle = 'rgba(255,0,0,0.3)';
- //this._game.stage.context.fillRect(this.scaledX, this.scaledY, this.worldView.width, this.worldView.height);
- this._game.stage.context.fillRect(this.worldView.x, this.worldView.y, this.worldView.width, this.worldView.height);
-
}
/**
diff --git a/Phaser/cameras/CameraManager.ts b/Phaser/cameras/CameraManager.ts
index 17cf6c31..191dc335 100644
--- a/Phaser/cameras/CameraManager.ts
+++ b/Phaser/cameras/CameraManager.ts
@@ -27,7 +27,8 @@ module Phaser {
this._cameras = [];
- this.current = this.addCamera(x, y, width, height);
+ this.default = this.addCamera(x, y, width, height);
+ this.current = this.default;
}
@@ -54,6 +55,11 @@ module Phaser {
*/
public current: Camera;
+ /**
+ * The default created camera.
+ */
+ public default: Camera;
+
/**
* Get all the cameras.
*
diff --git a/Phaser/components/sprite/Debug.ts b/Phaser/components/sprite/Debug.ts
index 5ffa22eb..421b5f52 100644
--- a/Phaser/components/sprite/Debug.ts
+++ b/Phaser/components/sprite/Debug.ts
@@ -67,23 +67,6 @@ module Phaser.Components {
}
*/
- /**
- * Render debug infos. (including name, bounds info, position and some other properties)
- * @param x {number} X position of the debug info to be rendered.
- * @param y {number} Y position of the debug info to be rendered.
- * @param [color] {number} color of the debug info to be rendered. (format is css color string)
- */
- /*
- public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
-
- this.context.fillStyle = color;
- this.context.fillText('Sprite: ' + this.name + ' (' + this.frameBounds.width + ' x ' + this.frameBounds.height + ')', x, y);
- this.context.fillText('x: ' + this.frameBounds.x.toFixed(1) + ' y: ' + this.frameBounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
- this.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
- this.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
-
- }
- */
}
diff --git a/Phaser/gameobjects/Sprite.ts b/Phaser/gameobjects/Sprite.ts
index 1bdda8c8..6a096f5a 100644
--- a/Phaser/gameobjects/Sprite.ts
+++ b/Phaser/gameobjects/Sprite.ts
@@ -43,6 +43,7 @@ module Phaser {
this.y = y;
this.z = -1;
this.group = null;
+ this.screen = new Point;
// If a texture has been given the body will be set to that size, otherwise 16x16
this.body = new Phaser.Physics.Body(this, bodyType);
@@ -159,6 +160,13 @@ module Phaser {
*/
public origin: Phaser.Vec2;
+ /**
+ * A Point holding the x/y coordinate of this Sprite relative to the screen. It uses the default created world
+ * camera to calculate its values. If you have changed the default camera (i.e. resized it, deleted it) this value
+ * will be incorrect and should be ignored.
+ */
+ public screen: Point;
+
/**
* x value of the object.
*/
@@ -249,6 +257,9 @@ module Phaser {
this.frameBounds.x = this.x;
this.frameBounds.y = this.y;
+ this.screen.x = this.x - (this.game.world.cameras.default.worldView.x * this.scrollFactor.x);
+ this.screen.y = this.y - (this.game.world.cameras.default.worldView.y * this.scrollFactor.y);
+
if (this.modified == false && (!this.scale.equals(1) || !this.skew.equals(0) || this.angle != 0 || this.angleOffset != 0 || this.texture.flippedX || this.texture.flippedY))
{
this.modified = true;
diff --git a/Phaser/utils/DebugUtils.ts b/Phaser/utils/DebugUtils.ts
new file mode 100644
index 00000000..8d76db9a
--- /dev/null
+++ b/Phaser/utils/DebugUtils.ts
@@ -0,0 +1,38 @@
+///
+///
+///
+///
+///
+///
+
+/**
+* Phaser - DebugUtils
+*
+* A collection of methods for displaying debug information about game objects.
+*/
+
+module Phaser {
+
+ export class DebugUtils {
+
+ static game: Game;
+
+ /**
+ * Render debug infos. (including name, bounds info, position and some other properties)
+ * @param x {number} X position of the debug info to be rendered.
+ * @param y {number} Y position of the debug info to be rendered.
+ * @param [color] {number} color of the debug info to be rendered. (format is css color string)
+ */
+ static renderSpriteInfo(sprite: Sprite, x: number, y: number, color?: string = 'rgb(255,255,255)') {
+
+ DebugUtils.game.stage.context.fillStyle = color;
+ DebugUtils.game.stage.context.fillText('Sprite: ' + ' (' + sprite.frameBounds.width + ' x ' + sprite.frameBounds.height + ')', x, y);
+ DebugUtils.game.stage.context.fillText('x: ' + sprite.frameBounds.x.toFixed(1) + ' y: ' + sprite.frameBounds.y.toFixed(1) + ' angle: ' + sprite.angle.toFixed(1), x, y + 14);
+ //DebugUtils.game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
+ //DebugUtils.game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
+
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/Phaser/utils/SpriteUtils.ts b/Phaser/utils/SpriteUtils.ts
index 5aa0f128..4b9253e0 100644
--- a/Phaser/utils/SpriteUtils.ts
+++ b/Phaser/utils/SpriteUtils.ts
@@ -17,6 +17,28 @@ module Phaser {
static _tempPoint: Point;
+ /**
+ * Check whether this object is visible in a specific camera rectangle.
+ * @param camera {Rectangle} The rectangle you want to check.
+ * @return {boolean} Return true if bounds of this sprite intersects the given rectangle, otherwise return false.
+ */
+ static inCamera(camera: Camera, sprite: Sprite): bool {
+
+ // Object fixed in place regardless of the camera scrolling? Then it's always visible
+ if (sprite.scrollFactor.x == 0 && sprite.scrollFactor.y == 0)
+ {
+ return true;
+ }
+
+ var dx = sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
+ var dy = sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
+ var dw = sprite.frameBounds.width * sprite.scale.x;
+ var dh = sprite.frameBounds.height * sprite.scale.y;
+
+ return (camera.scaledX + camera.worldView.width > this._dx) && (camera.scaledX < this._dx + this._dw) && (camera.scaledY + camera.worldView.height > this._dy) && (camera.scaledY < this._dy + this._dh);
+
+ }
+
static getAsPoints(sprite: Sprite): Phaser.Point[] {
var out: Phaser.Point[] = [];
@@ -200,7 +222,7 @@ module Phaser {
/**
* Call this to figure out the on-screen position of the object.
*
- * @param point {Point} Takes a MicroPoint object and assigns the post-scrolled X and Y values of this object to it.
+ * @param point {Point} Takes a Point object and assigns the post-scrolled X and Y values of this object to it.
* @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return {Point} The Point you passed in, or a new Point if you didn't pass one, containing the screen X and Y position of this object.
diff --git a/README.md b/README.md
index 74f0a478..c6b82ae0 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,8 @@ TODO:
* Bug: Sprite x/y gets shifted if dynamic from the original value
* Input CSS cursor those little 4-way arrows on drag?
* Stage CSS3 transforms!!! Color tints, sepia, greyscale, all of those cool things :)
+* Cameras should have option to be input disabled + Pointers should check which camera they are over before doing Sprite selection
+* Can Cameras be positioned within the world?
V1.0.0
@@ -77,6 +79,7 @@ V1.0.0
+
V0.9.6
* Virtually every class now has documentation - if you spot a typo or something missing please shout (thanks pixelpicosean).
diff --git a/Tests/input/world drag.js b/Tests/input/world drag.js
index 46c0779b..72191c9f 100644
--- a/Tests/input/world drag.js
+++ b/Tests/input/world drag.js
@@ -7,15 +7,16 @@
game.loader.addImageFile('melon', 'assets/sprites/melon.png');
game.loader.load();
}
+ var test;
function create() {
game.add.sprite(0, 0, 'backdrop');
for(var i = 0; i < 1; i++) {
//var sprite: Phaser.Sprite = game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
- var sprite = game.add.sprite(200, 200, 'melon');
- sprite.scrollFactor.setTo(2, 2);
- sprite.scale.setTo(2, 2);
- sprite.input.start(i, false, true);
- sprite.input.enableDrag();
+ //sprite.input.start(i, false, true);
+ //sprite.input.enableDrag();
+ test = game.add.sprite(700, 200, 'melon');
+ test.input.start(i, false, true);
+ test.input.enableDrag();
}
}
function update() {
@@ -32,5 +33,7 @@
}
function render() {
game.camera.renderDebugInfo(32, 32);
+ test.body.renderDebugInfo(300, 32);
+ Phaser.DebugUtils.renderSpriteInfo(test, 32, 200);
}
})();
diff --git a/Tests/input/world drag.ts b/Tests/input/world drag.ts
index b17ea12f..06fdcbcb 100644
--- a/Tests/input/world drag.ts
+++ b/Tests/input/world drag.ts
@@ -15,15 +15,23 @@
}
+ var test: Phaser.Sprite;
+
function create() {
game.add.sprite(0, 0, 'backdrop');
for (var i = 0; i < 1; i++)
{
- var sprite: Phaser.Sprite = game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
- sprite.input.start(i, false, true);
- sprite.input.enableDrag();
+ //var sprite: Phaser.Sprite = game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
+ //sprite.input.start(i, false, true);
+ //sprite.input.enableDrag();
+
+ test = game.add.sprite(700, 200, 'melon');
+ test.input.start(i, false, true);
+ test.input.enableDrag();
+
+
}
}
@@ -54,6 +62,10 @@
game.camera.renderDebugInfo(32, 32);
+ test.body.renderDebugInfo(300, 32);
+
+ Phaser.DebugUtils.renderSpriteInfo(test, 32, 200);
+
}
})();
diff --git a/Tests/phaser.js b/Tests/phaser.js
index c744697c..7c7d9a1f 100644
--- a/Tests/phaser.js
+++ b/Tests/phaser.js
@@ -5589,6 +5589,22 @@ var Phaser;
(function (Phaser) {
var SpriteUtils = (function () {
function SpriteUtils() { }
+ SpriteUtils.inCamera = /**
+ * Check whether this object is visible in a specific camera rectangle.
+ * @param camera {Rectangle} The rectangle you want to check.
+ * @return {boolean} Return true if bounds of this sprite intersects the given rectangle, otherwise return false.
+ */
+ function inCamera(camera, sprite) {
+ // Object fixed in place regardless of the camera scrolling? Then it's always visible
+ if(sprite.scrollFactor.x == 0 && sprite.scrollFactor.y == 0) {
+ return true;
+ }
+ var dx = sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
+ var dy = sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
+ var dw = sprite.frameBounds.width * sprite.scale.x;
+ var dh = sprite.frameBounds.height * sprite.scale.y;
+ return (camera.scaledX + camera.worldView.width > this._dx) && (camera.scaledX < this._dx + this._dw) && (camera.scaledY + camera.worldView.height > this._dy) && (camera.scaledY < this._dy + this._dh);
+ };
SpriteUtils.getAsPoints = function getAsPoints(sprite) {
var out = [];
// top left
@@ -5750,7 +5766,7 @@ var Phaser;
SpriteUtils.getScreenXY = /**
* Call this to figure out the on-screen position of the object.
*
- * @param point {Point} Takes a MicroPoint object and assigns the post-scrolled X and Y values of this object to it.
+ * @param point {Point} Takes a Point object and assigns the post-scrolled X and Y values of this object to it.
* @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return {Point} The Point you passed in, or a new Point if you didn't pass one, containing the screen X and Y position of this object.
@@ -7093,6 +7109,7 @@ var Phaser;
this.y = y;
this.z = -1;
this.group = null;
+ this.screen = new Phaser.Point();
// If a texture has been given the body will be set to that size, otherwise 16x16
this.body = new Phaser.Physics.Body(this, bodyType);
this.animations = new Phaser.Components.AnimationManager(this);
@@ -7180,6 +7197,8 @@ var Phaser;
function () {
this.frameBounds.x = this.x;
this.frameBounds.y = this.y;
+ this.screen.x = this.x - (this.game.camera.worldView.x * this.scrollFactor.x);
+ this.screen.y = this.y - (this.game.camera.worldView.y * this.scrollFactor.y);
if(this.modified == false && (!this.scale.equals(1) || !this.skew.equals(0) || this.angle != 0 || this.angleOffset != 0 || this.texture.flippedX || this.texture.flippedY)) {
this.modified = true;
}
@@ -7733,10 +7752,6 @@ var Phaser;
if(this.alpha !== 1) {
this._game.stage.context.globalAlpha = 1;
}
- // Debug test
- this._game.stage.context.fillStyle = 'rgba(255,0,0,0.3)';
- //this._game.stage.context.fillRect(this.scaledX, this.scaledY, this.worldView.width, this.worldView.height);
- this._game.stage.context.fillRect(this.worldView.x, this.worldView.y, this.worldView.width, this.worldView.height);
};
Camera.prototype.setPosition = /**
* Set position of this camera.
@@ -7879,7 +7894,8 @@ var Phaser;
this._cameraInstance = 0;
this._game = game;
this._cameras = [];
- this.current = this.addCamera(x, y, width, height);
+ this.default = this.addCamera(x, y, width, height);
+ this.current = this.default;
}
CameraManager.CAMERA_TYPE_ORTHOGRAPHIC = 0;
CameraManager.CAMERA_TYPE_ISOMETRIC = 1;
@@ -15489,7 +15505,6 @@ var Phaser;
*/
function (camera, sprite) {
if(sprite.scale.x == 0 || sprite.scale.y == 0 || sprite.texture.alpha < 0.1 || this.inCamera(camera, sprite) == false) {
- console.log('out of camera', sprite.frameBounds.x, sprite.frameBounds.y, sprite.frameBounds.width, sprite.frameBounds.height);
return false;
}
this._count++;
@@ -15665,6 +15680,39 @@ var Phaser;
})();
Phaser.CanvasRenderer = CanvasRenderer;
})(Phaser || (Phaser = {}));
+///
+///
+///
+///
+///
+///
+/**
+* Phaser - DebugUtils
+*
+* A collection of methods for displaying debug information about game objects.
+*/
+var Phaser;
+(function (Phaser) {
+ var DebugUtils = (function () {
+ function DebugUtils() { }
+ DebugUtils.renderSpriteInfo = /**
+ * Render debug infos. (including name, bounds info, position and some other properties)
+ * @param x {number} X position of the debug info to be rendered.
+ * @param y {number} Y position of the debug info to be rendered.
+ * @param [color] {number} color of the debug info to be rendered. (format is css color string)
+ */
+ function renderSpriteInfo(sprite, x, y, color) {
+ if (typeof color === "undefined") { color = 'rgb(255,255,255)'; }
+ DebugUtils.game.stage.context.fillStyle = color;
+ DebugUtils.game.stage.context.fillText('Sprite: ' + ' (' + sprite.frameBounds.width + ' x ' + sprite.frameBounds.height + ')', x, y);
+ DebugUtils.game.stage.context.fillText('x: ' + sprite.frameBounds.x.toFixed(1) + ' y: ' + sprite.frameBounds.y.toFixed(1) + ' angle: ' + sprite.angle.toFixed(1), x, y + 14);
+ //DebugUtils.game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
+ //DebugUtils.game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
+ };
+ return DebugUtils;
+ })();
+ Phaser.DebugUtils = DebugUtils;
+})(Phaser || (Phaser = {}));
///
///
///
@@ -15692,6 +15740,7 @@ var Phaser;
///
///
///
+///
/**
* Phaser - Game
*
@@ -15861,6 +15910,7 @@ var Phaser;
this.framerate = 60;
this.isBooted = true;
// Set-up some static helper references
+ Phaser.DebugUtils.game = this;
Phaser.ColorUtils.game = this;
// Display the default game screen?
if(this.onInitCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null) {
@@ -16191,23 +16241,6 @@ var Phaser;
//this.context.fillRect(this._dx + hw, this._dy + sh, 1, 1); // bottom center
//this.context.fillRect(this._dx + sw, this._dy + sh, 1, 1); // bottom right
- }
- */
- /**
- * Render debug infos. (including name, bounds info, position and some other properties)
- * @param x {number} X position of the debug info to be rendered.
- * @param y {number} Y position of the debug info to be rendered.
- * @param [color] {number} color of the debug info to be rendered. (format is css color string)
- */
- /*
- public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
-
- this.context.fillStyle = color;
- this.context.fillText('Sprite: ' + this.name + ' (' + this.frameBounds.width + ' x ' + this.frameBounds.height + ')', x, y);
- this.context.fillText('x: ' + this.frameBounds.x.toFixed(1) + ' y: ' + this.frameBounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
- this.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
- this.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
-
}
*/
})(Phaser.Components || (Phaser.Components = {}));
diff --git a/build/phaser.d.ts b/build/phaser.d.ts
index 4635f733..0aa0437a 100644
--- a/build/phaser.d.ts
+++ b/build/phaser.d.ts
@@ -3311,6 +3311,12 @@ module Phaser {
module Phaser {
class SpriteUtils {
static _tempPoint: Point;
+ /**
+ * Check whether this object is visible in a specific camera rectangle.
+ * @param camera {Rectangle} The rectangle you want to check.
+ * @return {boolean} Return true if bounds of this sprite intersects the given rectangle, otherwise return false.
+ */
+ static inCamera(camera: Camera, sprite: Sprite): bool;
static getAsPoints(sprite: Sprite): Point[];
/**
* Checks to see if a point in 2D world space overlaps this GameObject.
@@ -3333,7 +3339,7 @@ module Phaser {
/**
* Call this to figure out the on-screen position of the object.
*
- * @param point {Point} Takes a MicroPoint object and assigns the post-scrolled X and Y values of this object to it.
+ * @param point {Point} Takes a Point object and assigns the post-scrolled X and Y values of this object to it.
* @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return {Point} The Point you passed in, or a new Point if you didn't pass one, containing the screen X and Y position of this object.
@@ -4107,6 +4113,7 @@ module Phaser {
* The Sprite origin is the point around which scale and rotation takes place.
*/
public origin: Vec2;
+ public screen: Point;
/**
* x value of the object.
*/
@@ -4509,6 +4516,10 @@ module Phaser {
*/
public current: Camera;
/**
+ * The default created camera.
+ */
+ public default: Camera;
+ /**
* Get all the cameras.
*
* @returns {Camera[]} An array contains all the cameras.
@@ -8411,6 +8422,23 @@ module Phaser {
}
}
/**
+* Phaser - DebugUtils
+*
+* A collection of methods for displaying debug information about game objects.
+*/
+module Phaser {
+ class DebugUtils {
+ static game: Game;
+ /**
+ * Render debug infos. (including name, bounds info, position and some other properties)
+ * @param x {number} X position of the debug info to be rendered.
+ * @param y {number} Y position of the debug info to be rendered.
+ * @param [color] {number} color of the debug info to be rendered. (format is css color string)
+ */
+ static renderSpriteInfo(sprite: Sprite, x: number, y: number, color?: string): void;
+ }
+}
+/**
* Phaser - Game
*
* This is where the magic happens. The Game object is the heart of your game,
diff --git a/build/phaser.js b/build/phaser.js
index c744697c..7c7d9a1f 100644
--- a/build/phaser.js
+++ b/build/phaser.js
@@ -5589,6 +5589,22 @@ var Phaser;
(function (Phaser) {
var SpriteUtils = (function () {
function SpriteUtils() { }
+ SpriteUtils.inCamera = /**
+ * Check whether this object is visible in a specific camera rectangle.
+ * @param camera {Rectangle} The rectangle you want to check.
+ * @return {boolean} Return true if bounds of this sprite intersects the given rectangle, otherwise return false.
+ */
+ function inCamera(camera, sprite) {
+ // Object fixed in place regardless of the camera scrolling? Then it's always visible
+ if(sprite.scrollFactor.x == 0 && sprite.scrollFactor.y == 0) {
+ return true;
+ }
+ var dx = sprite.frameBounds.x - (camera.worldView.x * sprite.scrollFactor.x);
+ var dy = sprite.frameBounds.y - (camera.worldView.y * sprite.scrollFactor.y);
+ var dw = sprite.frameBounds.width * sprite.scale.x;
+ var dh = sprite.frameBounds.height * sprite.scale.y;
+ return (camera.scaledX + camera.worldView.width > this._dx) && (camera.scaledX < this._dx + this._dw) && (camera.scaledY + camera.worldView.height > this._dy) && (camera.scaledY < this._dy + this._dh);
+ };
SpriteUtils.getAsPoints = function getAsPoints(sprite) {
var out = [];
// top left
@@ -5750,7 +5766,7 @@ var Phaser;
SpriteUtils.getScreenXY = /**
* Call this to figure out the on-screen position of the object.
*
- * @param point {Point} Takes a MicroPoint object and assigns the post-scrolled X and Y values of this object to it.
+ * @param point {Point} Takes a Point object and assigns the post-scrolled X and Y values of this object to it.
* @param camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return {Point} The Point you passed in, or a new Point if you didn't pass one, containing the screen X and Y position of this object.
@@ -7093,6 +7109,7 @@ var Phaser;
this.y = y;
this.z = -1;
this.group = null;
+ this.screen = new Phaser.Point();
// If a texture has been given the body will be set to that size, otherwise 16x16
this.body = new Phaser.Physics.Body(this, bodyType);
this.animations = new Phaser.Components.AnimationManager(this);
@@ -7180,6 +7197,8 @@ var Phaser;
function () {
this.frameBounds.x = this.x;
this.frameBounds.y = this.y;
+ this.screen.x = this.x - (this.game.camera.worldView.x * this.scrollFactor.x);
+ this.screen.y = this.y - (this.game.camera.worldView.y * this.scrollFactor.y);
if(this.modified == false && (!this.scale.equals(1) || !this.skew.equals(0) || this.angle != 0 || this.angleOffset != 0 || this.texture.flippedX || this.texture.flippedY)) {
this.modified = true;
}
@@ -7733,10 +7752,6 @@ var Phaser;
if(this.alpha !== 1) {
this._game.stage.context.globalAlpha = 1;
}
- // Debug test
- this._game.stage.context.fillStyle = 'rgba(255,0,0,0.3)';
- //this._game.stage.context.fillRect(this.scaledX, this.scaledY, this.worldView.width, this.worldView.height);
- this._game.stage.context.fillRect(this.worldView.x, this.worldView.y, this.worldView.width, this.worldView.height);
};
Camera.prototype.setPosition = /**
* Set position of this camera.
@@ -7879,7 +7894,8 @@ var Phaser;
this._cameraInstance = 0;
this._game = game;
this._cameras = [];
- this.current = this.addCamera(x, y, width, height);
+ this.default = this.addCamera(x, y, width, height);
+ this.current = this.default;
}
CameraManager.CAMERA_TYPE_ORTHOGRAPHIC = 0;
CameraManager.CAMERA_TYPE_ISOMETRIC = 1;
@@ -15489,7 +15505,6 @@ var Phaser;
*/
function (camera, sprite) {
if(sprite.scale.x == 0 || sprite.scale.y == 0 || sprite.texture.alpha < 0.1 || this.inCamera(camera, sprite) == false) {
- console.log('out of camera', sprite.frameBounds.x, sprite.frameBounds.y, sprite.frameBounds.width, sprite.frameBounds.height);
return false;
}
this._count++;
@@ -15665,6 +15680,39 @@ var Phaser;
})();
Phaser.CanvasRenderer = CanvasRenderer;
})(Phaser || (Phaser = {}));
+///
+///
+///
+///
+///
+///
+/**
+* Phaser - DebugUtils
+*
+* A collection of methods for displaying debug information about game objects.
+*/
+var Phaser;
+(function (Phaser) {
+ var DebugUtils = (function () {
+ function DebugUtils() { }
+ DebugUtils.renderSpriteInfo = /**
+ * Render debug infos. (including name, bounds info, position and some other properties)
+ * @param x {number} X position of the debug info to be rendered.
+ * @param y {number} Y position of the debug info to be rendered.
+ * @param [color] {number} color of the debug info to be rendered. (format is css color string)
+ */
+ function renderSpriteInfo(sprite, x, y, color) {
+ if (typeof color === "undefined") { color = 'rgb(255,255,255)'; }
+ DebugUtils.game.stage.context.fillStyle = color;
+ DebugUtils.game.stage.context.fillText('Sprite: ' + ' (' + sprite.frameBounds.width + ' x ' + sprite.frameBounds.height + ')', x, y);
+ DebugUtils.game.stage.context.fillText('x: ' + sprite.frameBounds.x.toFixed(1) + ' y: ' + sprite.frameBounds.y.toFixed(1) + ' angle: ' + sprite.angle.toFixed(1), x, y + 14);
+ //DebugUtils.game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
+ //DebugUtils.game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
+ };
+ return DebugUtils;
+ })();
+ Phaser.DebugUtils = DebugUtils;
+})(Phaser || (Phaser = {}));
///
///
///
@@ -15692,6 +15740,7 @@ var Phaser;
///
///
///
+///
/**
* Phaser - Game
*
@@ -15861,6 +15910,7 @@ var Phaser;
this.framerate = 60;
this.isBooted = true;
// Set-up some static helper references
+ Phaser.DebugUtils.game = this;
Phaser.ColorUtils.game = this;
// Display the default game screen?
if(this.onInitCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null) {
@@ -16191,23 +16241,6 @@ var Phaser;
//this.context.fillRect(this._dx + hw, this._dy + sh, 1, 1); // bottom center
//this.context.fillRect(this._dx + sw, this._dy + sh, 1, 1); // bottom right
- }
- */
- /**
- * Render debug infos. (including name, bounds info, position and some other properties)
- * @param x {number} X position of the debug info to be rendered.
- * @param y {number} Y position of the debug info to be rendered.
- * @param [color] {number} color of the debug info to be rendered. (format is css color string)
- */
- /*
- public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
-
- this.context.fillStyle = color;
- this.context.fillText('Sprite: ' + this.name + ' (' + this.frameBounds.width + ' x ' + this.frameBounds.height + ')', x, y);
- this.context.fillText('x: ' + this.frameBounds.x.toFixed(1) + ' y: ' + this.frameBounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
- this.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
- this.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
-
}
*/
})(Phaser.Components || (Phaser.Components = {}));