Updating all files to adhere to the JSHint settings and fixing lots of documentation errors on the way.

This commit is contained in:
photonstorm
2013-11-25 03:13:04 +00:00
parent 373b97648d
commit 13a2cc2feb
68 changed files with 4622 additions and 4628 deletions
File diff suppressed because it is too large Load Diff
+45 -37
View File
@@ -25,28 +25,28 @@ Phaser.BitmapText = function (game, x, y, text, style) {
text = text || '';
style = style || '';
/**
* @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
* @default
*/
/**
* @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
* @default
*/
this.exists = true;
/**
/**
* @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.
* @default
*/
* @default
*/
this.alive = true;
/**
/**
* @property {Description} group - Description.
* @default
*/
* @default
*/
this.group = null;
/**
/**
* @property {string} name - Description.
* @default
*/
* @default
*/
this.name = '';
/**
@@ -61,54 +61,62 @@ Phaser.BitmapText = function (game, x, y, text, style) {
*/
this.type = Phaser.BITMAPTEXT;
/**
* @property {number} position.x - Description.
*/
/**
* @property {number} position.x - Description.
*/
this.position.x = x;
/**
* @property {number} position.y - Description.
*/
/**
* @property {number} position.y - Description.
*/
this.position.y = y;
// Replaces the PIXI.Point with a slightly more flexible one
/**
* @property {Phaser.Point} anchor - Description.
*/
/**
* @property {Phaser.Point} anchor - Description.
*/
this.anchor = new Phaser.Point();
/**
* @property {Phaser.Point} scale - Description.
*/
/**
* @property {Phaser.Point} scale - Description.
*/
this.scale = new Phaser.Point(1, 1);
// A mini cache for storing all of the calculated values
/**
* @property {function} _cache - Description.
* @private
*/
this._cache = {
/**
* @property {function} _cache - Description.
* @private
*/
this._cache = {
dirty: false,
// Transform cache
a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1,
a00: 1,
a01: 0,
a02: x,
a10: 0,
a11: 1,
a12: y,
id: 1,
// The previous calculated position
x: -1, y: -1,
x: -1,
y: -1,
// The actual scale values based on the worldTransform
scaleX: 1, scaleY: 1
scaleX: 1,
scaleY: 1
};
this._cache.x = this.x;
this._cache.y = this.y;
/**
* @property {boolean} renderable - Description.
* @private
*/
/**
* @property {boolean} renderable - Description.
* @private
*/
this.renderable = true;
};
+67 -67
View File
@@ -33,67 +33,67 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
callback = callback || null;
callbackContext = callbackContext || this;
Phaser.Sprite.call(this, game, x, y, key, outFrame);
Phaser.Sprite.call(this, game, x, y, key, outFrame);
/**
* @property {number} type - The Phaser Object Type.
*/
/**
* @property {number} type - The Phaser Object Type.
*/
this.type = Phaser.BUTTON;
/**
* @property {string} _onOverFrameName - Internal variable.
* @private
* @default
*/
/**
* @property {string} _onOverFrameName - Internal variable.
* @private
* @default
*/
this._onOverFrameName = null;
/**
* @property {string} _onOutFrameName - Internal variable.
* @private
* @default
*/
/**
* @property {string} _onOutFrameName - Internal variable.
* @private
* @default
*/
this._onOutFrameName = null;
/**
* @property {string} _onDownFrameName - Internal variable.
* @private
* @default
*/
/**
* @property {string} _onDownFrameName - Internal variable.
* @private
* @default
*/
this._onDownFrameName = null;
/**
* @property {string} _onUpFrameName - Internal variable.
* @private
* @default
*/
/**
* @property {string} _onUpFrameName - Internal variable.
* @private
* @default
*/
this._onUpFrameName = null;
/**
* @property {number} _onOverFrameID - Internal variable.
* @private
* @default
*/
/**
* @property {number} _onOverFrameID - Internal variable.
* @private
* @default
*/
this._onOverFrameID = null;
/**
* @property {number} _onOutFrameID - Internal variable.
* @private
* @default
*/
/**
* @property {number} _onOutFrameID - Internal variable.
* @private
* @default
*/
this._onOutFrameID = null;
/**
* @property {number} _onDownFrameID - Internal variable.
* @private
* @default
*/
/**
* @property {number} _onDownFrameID - Internal variable.
* @private
* @default
*/
this._onDownFrameID = null;
/**
* @property {number} _onUpFrameID - Internal variable.
* @private
* @default
*/
/**
* @property {number} _onUpFrameID - Internal variable.
* @private
* @default
*/
this._onUpFrameID = null;
/**
@@ -144,25 +144,25 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
*/
this.onUpSoundMarker = '';
/**
* @property {Phaser.Signal} onInputOver - The Signal (or event) dispatched when this Button is in an Over state.
*/
this.onInputOver = new Phaser.Signal;
/**
* @property {Phaser.Signal} onInputOver - The Signal (or event) dispatched when this Button is in an Over state.
*/
this.onInputOver = new Phaser.Signal();
/**
* @property {Phaser.Signal} onInputOut - The Signal (or event) dispatched when this Button is in an Out state.
*/
this.onInputOut = new Phaser.Signal;
/**
* @property {Phaser.Signal} onInputOut - The Signal (or event) dispatched when this Button is in an Out state.
*/
this.onInputOut = new Phaser.Signal();
/**
* @property {Phaser.Signal} onInputDown - The Signal (or event) dispatched when this Button is in an Down state.
*/
this.onInputDown = new Phaser.Signal;
/**
* @property {Phaser.Signal} onInputDown - The Signal (or event) dispatched when this Button is in an Down state.
*/
this.onInputDown = new Phaser.Signal();
/**
* @property {Phaser.Signal} onInputUp - The Signal (or event) dispatched when this Button is in an Up state.
*/
this.onInputUp = new Phaser.Signal;
/**
* @property {Phaser.Signal} onInputUp - The Signal (or event) dispatched when this Button is in an Up state.
*/
this.onInputUp = new Phaser.Signal();
/**
* @property {boolean} freezeFrames - When true the Button will cease to change texture frame on all events (over, out, up, down).
@@ -237,7 +237,7 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) {
this._onOutFrameName = outFrame;
this._onUpFrameName = outFrame;
if (this.input.pointerOver() == false)
if (this.input.pointerOver() === false)
{
this.frameName = outFrame;
}
@@ -247,7 +247,7 @@ Phaser.Button.prototype.setFrames = function (overFrame, outFrame, downFrame) {
this._onOutFrameID = outFrame;
this._onUpFrameID = outFrame;
if (this.input.pointerOver() == false)
if (this.input.pointerOver() === false)
{
this.frame = outFrame;
}
@@ -407,7 +407,7 @@ Phaser.Button.prototype.setDownSound = function (sound, marker) {
*/
Phaser.Button.prototype.onInputOverHandler = function (pointer) {
if (this.freezeFrames == false)
if (this.freezeFrames === false)
{
if (this._onOverFrameName != null)
{
@@ -439,7 +439,7 @@ Phaser.Button.prototype.onInputOverHandler = function (pointer) {
*/
Phaser.Button.prototype.onInputOutHandler = function (pointer) {
if (this.freezeFrames == false)
if (this.freezeFrames === false)
{
if (this._onOutFrameName != null)
{
@@ -471,7 +471,7 @@ Phaser.Button.prototype.onInputOutHandler = function (pointer) {
*/
Phaser.Button.prototype.onInputDownHandler = function (pointer) {
if (this.freezeFrames == false)
if (this.freezeFrames === false)
{
if (this._onDownFrameName != null)
{
@@ -503,7 +503,7 @@ Phaser.Button.prototype.onInputDownHandler = function (pointer) {
*/
Phaser.Button.prototype.onInputUpHandler = function (pointer) {
if (this.freezeFrames == false)
if (this.freezeFrames === false)
{
if (this._onUpFrameName != null)
{
@@ -520,7 +520,7 @@ Phaser.Button.prototype.onInputUpHandler = function (pointer) {
this.onUpSound.play(this.onUpSoundMarker);
}
if (this.forceOut && this.freezeFrames == false)
if (this.forceOut && this.freezeFrames === false)
{
if (this._onOutFrameName != null)
{
+33 -34
View File
@@ -4,7 +4,6 @@
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* The Events component is a collection of events fired by the parent game object and its components.
*
@@ -14,13 +13,13 @@
* @param {Phaser.Sprite} sprite - A reference to Description.
*/
Phaser.Events = function (sprite) {
this.parent = sprite;
this.onAddedToGroup = new Phaser.Signal;
this.onRemovedFromGroup = new Phaser.Signal;
this.onKilled = new Phaser.Signal;
this.onRevived = new Phaser.Signal;
this.onOutOfBounds = new Phaser.Signal;
this.parent = sprite;
this.onAddedToGroup = new Phaser.Signal();
this.onRemovedFromGroup = new Phaser.Signal();
this.onKilled = new Phaser.Signal();
this.onRevived = new Phaser.Signal();
this.onOutOfBounds = new Phaser.Signal();
this.onInputOver = null;
this.onInputOut = null;
@@ -29,40 +28,40 @@ Phaser.Events = function (sprite) {
this.onDragStart = null;
this.onDragStop = null;
this.onAnimationStart = null;
this.onAnimationComplete = null;
this.onAnimationLoop = null;
this.onAnimationStart = null;
this.onAnimationComplete = null;
this.onAnimationLoop = null;
};
Phaser.Events.prototype = {
destroy: function () {
destroy: function () {
this.parent = null;
this.onAddedToGroup.dispose();
this.onRemovedFromGroup.dispose();
this.onKilled.dispose();
this.onRevived.dispose();
this.onOutOfBounds.dispose();
this.parent = null;
this.onAddedToGroup.dispose();
this.onRemovedFromGroup.dispose();
this.onKilled.dispose();
this.onRevived.dispose();
this.onOutOfBounds.dispose();
if (this.onInputOver)
{
this.onInputOver.dispose();
this.onInputOut.dispose();
this.onInputDown.dispose();
this.onInputUp.dispose();
this.onDragStart.dispose();
this.onDragStop.dispose();
}
if (this.onInputOver)
{
this.onInputOver.dispose();
this.onInputOut.dispose();
this.onInputDown.dispose();
this.onInputUp.dispose();
this.onDragStart.dispose();
this.onDragStop.dispose();
}
if (this.onAnimationStart)
{
this.onAnimationStart.dispose();
this.onAnimationComplete.dispose();
this.onAnimationLoop.dispose();
}
if (this.onAnimationStart)
{
this.onAnimationStart.dispose();
this.onAnimationComplete.dispose();
this.onAnimationLoop.dispose();
}
}
}
};
+8 -8
View File
@@ -14,14 +14,14 @@
Phaser.GameObjectFactory = function (game) {
/**
* @property {Phaser.Game} game - A reference to the currently running Game.
*/
this.game = game;
* @property {Phaser.Game} game - A reference to the currently running Game.
*/
this.game = game;
/**
* @property {Phaser.World} world - A reference to the game world.
*/
this.world = this.game.world;
* @property {Phaser.World} world - A reference to the game world.
*/
this.world = this.game.world;
};
@@ -39,7 +39,7 @@ Phaser.GameObjectFactory.prototype = {
},
/**
/**
* Create a new Sprite with specific position and sprite sheet key.
*
* @method Phaser.GameObjectFactory#sprite
+7 -9
View File
@@ -5,7 +5,7 @@
*/
/**
* Creates a new <code>Graphics</code> object.
* Creates a new `Graphics` object.
*
* @class Phaser.Graphics
* @constructor
@@ -21,22 +21,20 @@ Phaser.Graphics = function (game, x, y) {
PIXI.Graphics.call(this);
/**
* @property {Description} type - Description.
* @property {number} type - The Phaser Object Type.
*/
this.type = Phaser.GRAPHICS;
this.position.x = x;
this.position.y = y;
this.position.y = y;
};
Phaser.Graphics.prototype = Object.create(PIXI.Graphics.prototype);
Phaser.Graphics.prototype.constructor = Phaser.Graphics;
// Add our own custom methods
/**
* Description.
* Destroy this Graphics instance.
*
* @method Phaser.Sprite.prototype.destroy
*/
@@ -58,14 +56,14 @@ Phaser.Graphics.prototype.destroy = function() {
*/
Phaser.Graphics.prototype.drawPolygon = function (poly) {
graphics.moveTo(poly.points[0].x, poly.points[0].y);
this.moveTo(poly.points[0].x, poly.points[0].y);
for (var i = 1; i < poly.points.length; i += 1)
{
graphics.lineTo(poly.points[i].x, poly.points[i].y);
this.lineTo(poly.points[i].x, poly.points[i].y);
}
graphics.lineTo(poly.points[0].x, poly.points[0].y);
this.lineTo(poly.points[0].x, poly.points[0].y);
}
+165 -161
View File
@@ -15,54 +15,54 @@
*/
Phaser.RenderTexture = function (game, key, width, height) {
/**
* @property {Phaser.Game} game - A reference to the currently running game.
*/
this.game = game;
/**
* @property {Phaser.Game} game - A reference to the currently running game.
*/
this.game = game;
/**
/**
* @property {string} name - the name of the object.
*/
*/
this.name = key;
PIXI.EventTarget.call(this);
PIXI.EventTarget.call(this);
/**
* @property {number} width - the width.
/**
* @property {number} width - the width.
*/
this.width = width || 100;
/**
* @property {number} height - the height.
this.width = width || 100;
/**
* @property {number} height - the height.
*/
this.height = height || 100;
this.height = height || 100;
/**
/**
* @property {PIXI.mat3} indetityMatrix - Matrix object.
*/
this.indetityMatrix = PIXI.mat3.create();
/**
* @property {PIXI.Rectangle} frame - The frame for this texture.
*/
this.frame = new PIXI.Rectangle(0, 0, this.width, this.height);
this.indetityMatrix = PIXI.mat3.create();
/**
* @property {number} type - Base Phaser object type.
/**
* @property {PIXI.Rectangle} frame - The frame for this texture.
*/
this.type = Phaser.RENDERTEXTURE;
this.frame = new PIXI.Rectangle(0, 0, this.width, this.height);
this._tempPoint = { x: 0, y: 0 };
/**
* @property {number} type - Base Phaser object type.
*/
this.type = Phaser.RENDERTEXTURE;
if (PIXI.gl)
{
this.initWebGL();
}
else
{
this.initCanvas();
}
this._tempPoint = { x: 0, y: 0 };
if (PIXI.gl)
{
this.initWebGL();
}
else
{
this.initCanvas();
}
};
Phaser.RenderTexture.prototype = Object.create(PIXI.Texture.prototype);
@@ -79,22 +79,22 @@ Phaser.RenderTexture.prototype.constructor = PIXI.RenderTexture;
*/
Phaser.RenderTexture.prototype.render = function(displayObject, position, clear) {
if (typeof position === 'undefined') { position = false; }
if (typeof clear === 'undefined') { clear = false; }
if (typeof position === 'undefined') { position = false; }
if (typeof clear === 'undefined') { clear = false; }
if (displayObject instanceof Phaser.Group)
{
displayObject = displayObject._container;
}
if (displayObject instanceof Phaser.Group)
{
displayObject = displayObject._container;
}
if (PIXI.gl)
{
this.renderWebGL(displayObject, position, clear);
}
else
{
this.renderCanvas(displayObject, position, clear);
}
if (PIXI.gl)
{
this.renderWebGL(displayObject, position, clear);
}
else
{
this.renderCanvas(displayObject, position, clear);
}
}
@@ -110,10 +110,10 @@ Phaser.RenderTexture.prototype.render = function(displayObject, position, clear)
*/
Phaser.RenderTexture.prototype.renderXY = function(displayObject, x, y, clear) {
this._tempPoint.x = x;
this._tempPoint.y = y;
this._tempPoint.x = x;
this._tempPoint.y = y;
this.render(displayObject, this._tempPoint, clear);
this.render(displayObject, this._tempPoint, clear);
}
@@ -125,64 +125,64 @@ Phaser.RenderTexture.prototype.renderXY = function(displayObject, x, y, clear) {
*/
Phaser.RenderTexture.prototype.initWebGL = function()
{
var gl = PIXI.gl;
this.glFramebuffer = gl.createFramebuffer();
var gl = PIXI.gl;
this.glFramebuffer = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer );
gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer );
this.glFramebuffer.width = this.width;
this.glFramebuffer.height = this.height;
this.glFramebuffer.height = this.height;
this.baseTexture = new PIXI.BaseTexture();
this.baseTexture = new PIXI.BaseTexture();
this.baseTexture.width = this.width;
this.baseTexture.height = this.height;
this.baseTexture.width = this.width;
this.baseTexture.height = this.height;
this.baseTexture._glTexture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTexture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
this.baseTexture.isRender = true;
this.baseTexture.isRender = true;
gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer );
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.baseTexture._glTexture, 0);
gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer );
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.baseTexture._glTexture, 0);
// create a projection matrix..
this.projection = new PIXI.Point(this.width/2 , -this.height/2);
// create a projection matrix..
this.projection = new PIXI.Point(this.width/2 , -this.height/2);
// set the correct render function..
// this.render = this.renderWebGL;
// set the correct render function..
// this.render = this.renderWebGL;
}
Phaser.RenderTexture.prototype.resize = function(width, height)
{
this.width = width;
this.height = height;
if(PIXI.gl)
{
this.projection.x = this.width/2
this.projection.y = -this.height/2;
var gl = PIXI.gl;
gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTexture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
}
else
{
this.frame.width = this.width
this.frame.height = this.height;
this.renderer.resize(this.width, this.height);
}
this.width = width;
this.height = height;
if(PIXI.gl)
{
this.projection.x = this.width/2
this.projection.y = -this.height/2;
var gl = PIXI.gl;
gl.bindTexture(gl.TEXTURE_2D, this.baseTexture._glTexture);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this.width, this.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
}
else
{
this.frame.width = this.width
this.frame.height = this.height;
this.renderer.resize(this.width, this.height);
}
}
/**
@@ -193,12 +193,12 @@ Phaser.RenderTexture.prototype.resize = function(width, height)
*/
Phaser.RenderTexture.prototype.initCanvas = function()
{
this.renderer = new PIXI.CanvasRenderer(this.width, this.height, null, 0);
this.renderer = new PIXI.CanvasRenderer(this.width, this.height, null, 0);
this.baseTexture = new PIXI.BaseTexture(this.renderer.view);
this.frame = new PIXI.Rectangle(0, 0, this.width, this.height);
this.baseTexture = new PIXI.BaseTexture(this.renderer.view);
this.frame = new PIXI.Rectangle(0, 0, this.width, this.height);
// this.render = this.renderCanvas;
// this.render = this.renderCanvas;
}
/**
@@ -211,69 +211,72 @@ Phaser.RenderTexture.prototype.initCanvas = function()
*/
Phaser.RenderTexture.prototype.renderWebGL = function(displayObject, position, clear)
{
var gl = PIXI.gl;
var gl = PIXI.gl;
// enable the alpha color mask..
gl.colorMask(true, true, true, true);
// enable the alpha color mask..
gl.colorMask(true, true, true, true);
gl.viewport(0, 0, this.width, this.height);
gl.viewport(0, 0, this.width, this.height);
gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer );
gl.bindFramebuffer(gl.FRAMEBUFFER, this.glFramebuffer );
if(clear)
{
gl.clearColor(0,0,0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
}
if (clear)
{
gl.clearColor(0,0,0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
}
// THIS WILL MESS WITH HIT TESTING!
var children = displayObject.children;
// THIS WILL MESS WITH HIT TESTING!
var children = displayObject.children;
//TODO -? create a new one??? dont think so!
var originalWorldTransform = displayObject.worldTransform;
displayObject.worldTransform = PIXI.mat3.create();//sthis.indetityMatrix;
// modify to flip...
displayObject.worldTransform[4] = -1;
displayObject.worldTransform[5] = this.projection.y * -2;
//TODO -? create a new one??? dont think so!
var originalWorldTransform = displayObject.worldTransform;
displayObject.worldTransform = PIXI.mat3.create();//sthis.indetityMatrix;
// modify to flip...
displayObject.worldTransform[4] = -1;
displayObject.worldTransform[5] = this.projection.y * -2;
if(position)
{
displayObject.worldTransform[2] = position.x;
displayObject.worldTransform[5] -= position.y;
}
PIXI.visibleCount++;
displayObject.vcount = PIXI.visibleCount;
for(var i=0,j=children.length; i<j; i++)
{
children[i].updateTransform();
}
if (position)
{
displayObject.worldTransform[2] = position.x;
displayObject.worldTransform[5] -= position.y;
}
PIXI.visibleCount++;
displayObject.vcount = PIXI.visibleCount;
for (var i = 0, j = children.length; i < j; i++)
{
children[i].updateTransform();
}
var renderGroup = displayObject.__renderGroup;
var renderGroup = displayObject.__renderGroup;
if(renderGroup)
{
if(displayObject == renderGroup.root)
{
renderGroup.render(this.projection, this.glFramebuffer);
}
else
{
renderGroup.renderSpecific(displayObject, this.projection, this.glFramebuffer);
}
}
else
{
if(!this.renderGroup)this.renderGroup = new PIXI.WebGLRenderGroup(gl);
this.renderGroup.setRenderable(displayObject);
this.renderGroup.render(this.projection, this.glFramebuffer);
}
displayObject.worldTransform = originalWorldTransform;
if (renderGroup)
{
if (displayObject == renderGroup.root)
{
renderGroup.render(this.projection, this.glFramebuffer);
}
else
{
renderGroup.renderSpecific(displayObject, this.projection, this.glFramebuffer);
}
}
else
{
if (!this.renderGroup)
{
this.renderGroup = new PIXI.WebGLRenderGroup(gl);
}
this.renderGroup.setRenderable(displayObject);
this.renderGroup.render(this.projection, this.glFramebuffer);
}
displayObject.worldTransform = originalWorldTransform;
}
/**
* This function will draw the display object to the texture.
*
@@ -284,28 +287,29 @@ Phaser.RenderTexture.prototype.renderWebGL = function(displayObject, position, c
*/
Phaser.RenderTexture.prototype.renderCanvas = function(displayObject, position, clear)
{
var children = displayObject.children;
var children = displayObject.children;
displayObject.worldTransform = PIXI.mat3.create();
if(position)
{
displayObject.worldTransform[2] = position.x;
displayObject.worldTransform[5] = position.y;
}
displayObject.worldTransform = PIXI.mat3.create();
if (position)
{
displayObject.worldTransform[2] = position.x;
displayObject.worldTransform[5] = position.y;
}
for(var i=0,j=children.length; i<j; i++)
{
children[i].updateTransform();
}
for (var i = 0, j = children.length; i < j; i++)
{
children[i].updateTransform();
}
if(clear)this.renderer.context.clearRect(0,0, this.width, this.height);
if (clear)
{
this.renderer.context.clearRect(0, 0, this.width, this.height);
}
this.renderer.renderDisplayObject(displayObject);
this.renderer.context.setTransform(1,0,0,1,0,0);
this.renderer.context.setTransform(1, 0, 0, 1, 0, 0);
// PIXI.texturesToUpdate.push(this.baseTexture);
}
+71 -49
View File
@@ -26,51 +26,51 @@ Phaser.Sprite = function (game, x, y, key, frame) {
frame = frame || null;
/**
* @property {Phaser.Game} game - A reference to the currently running Game.
*/
this.game = game;
* @property {Phaser.Game} game - A reference to the currently running Game.
*/
this.game = game;
/**
* @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
* @default
*/
/**
* @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
* @default
*/
this.exists = true;
/**
/**
* @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.
* @default
*/
* @default
*/
this.alive = true;
/**
/**
* @property {Phaser.Group} group - The parent Group of this Sprite. This is usually set after Sprite instantiation by the parent.
*/
*/
this.group = null;
/**
* @property {string} name - The user defined name given to this Sprite.
* @default
*/
* @property {string} name - The user defined name given to this Sprite.
* @default
*/
this.name = '';
/**
* @property {number} type - The const type of this object.
* @default
*/
* @property {number} type - The const type of this object.
* @readonly
*/
this.type = Phaser.SPRITE;
/**
* @property {number} renderOrderID - Used by the Renderer and Input Manager to control picking order.
* @default
*/
* @property {number} renderOrderID - Used by the Renderer and Input Manager to control picking order.
* @default
*/
this.renderOrderID = -1;
/**
* If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc.
* The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called.
* @property {number} lifespan - The lifespan of the Sprite (in ms) before it will be killed.
* @default
*/
* The lifespan is decremented by game.time.elapsed each update, once it reaches zero the kill() function is called.
* @property {number} lifespan - The lifespan of the Sprite (in ms) before it will be killed.
* @default
*/
this.lifespan = 0;
/**
@@ -123,7 +123,7 @@ Phaser.Sprite = function (game, x, y, key, frame) {
key = '__default';
this.key = key;
}
else if (typeof key === 'string' && this.game.cache.checkImageKey(key) == false)
else if (typeof key === 'string' && this.game.cache.checkImageKey(key) === false)
{
key = '__missing';
this.key = key;
@@ -179,8 +179,8 @@ Phaser.Sprite = function (game, x, y, key, frame) {
*/
this.y = y;
this.position.x = x;
this.position.y = y;
this.position.x = x;
this.position.y = y;
/**
* @property {Phaser.Point} world - The world coordinates of this Sprite. This differs from the x/y coordinates which are relative to the Sprites container.
@@ -198,60 +198,82 @@ Phaser.Sprite = function (game, x, y, key, frame) {
/**
* @property {Phaser.Point} scale - The scale of the Sprite when rendered. By default it's set to 1 (no scale). You can modify it via scale.x or scale.y or scale.setTo(x, y). A value of 1 means no change to the scale, 0.5 means "half the size", 2 means "twice the size", etc.
*/
*/
this.scale = new Phaser.Point(1, 1);
/**
* @property {Phaser.Point} _cache - A mini cache for storing all of the calculated values.
* @property {object} _cache - A mini cache for storing all of the calculated values.
* @private
*/
this._cache = {
this._cache = {
dirty: false,
// Transform cache
a00: -1, a01: -1, a02: -1, a10: -1, a11: -1, a12: -1, id: -1,
a00: -1,
a01: -1,
a02: -1,
a10: -1,
a11: -1,
a12: -1,
id: -1,
// Input specific transform cache
i01: -1, i10: -1, idi: -1,
i01: -1,
i10: -1,
idi: -1,
// Bounds check
left: null, right: null, top: null, bottom: null,
left: null,
right: null,
top: null,
bottom: null,
// delta cache
prevX: x, prevY: y,
prevX: x,
prevY: y,
// The previous calculated position
x: -1, y: -1,
x: -1,
y: -1,
// The actual scale values based on the worldTransform
scaleX: 1, scaleY: 1,
scaleX: 1,
scaleY: 1,
// The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size
width: this.currentFrame.sourceSizeW, height: this.currentFrame.sourceSizeH,
width: this.currentFrame.sourceSizeW,
height: this.currentFrame.sourceSizeH,
// The actual width/height of the image if from a trimmed atlas, multiplied by the final calculated scale size
halfWidth: Math.floor(this.currentFrame.sourceSizeW / 2), halfHeight: Math.floor(this.currentFrame.sourceSizeH / 2),
halfWidth: Math.floor(this.currentFrame.sourceSizeW / 2),
halfHeight: Math.floor(this.currentFrame.sourceSizeH / 2),
// The width/height of the image, based on the un-modified frame size multiplied by the final calculated scale size
calcWidth: -1, calcHeight: -1,
calcWidth: -1,
calcHeight: -1,
// The current frame details
// frameID: this.currentFrame.uuid, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height,
frameID: -1, frameWidth: this.currentFrame.width, frameHeight: this.currentFrame.height,
frameID: -1,
frameWidth: this.currentFrame.width,
frameHeight: this.currentFrame.height,
// If this sprite visible to the camera (regardless of being set to visible or not)
cameraVisible: true,
// Crop cache
cropX: 0, cropY: 0, cropWidth: this.currentFrame.sourceSizeW, cropHeight: this.currentFrame.sourceSizeH
cropX: 0,
cropY: 0,
cropWidth: this.currentFrame.sourceSizeW,
cropHeight: this.currentFrame.sourceSizeH
};
/**
* @property {Phaser.Point} offset - Corner point defaults. Should not typically be modified.
*/
this.offset = new Phaser.Point;
*/
this.offset = new Phaser.Point();
/**
* @property {Phaser.Point} center - A Point containing the center coordinate of the Sprite. Takes rotation and scale into account.
@@ -293,7 +315,7 @@ Phaser.Sprite = function (game, x, y, key, frame) {
/**
* @property {number} health - Health value. Used in combination with damage() to allow for quick killing of Sprites.
*/
*/
this.health = 1;
/**
@@ -330,7 +352,7 @@ Phaser.Sprite = function (game, x, y, key, frame) {
/**
* @property {Phaser.Point} cameraOffset - If this Sprite is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered.
*/
this.cameraOffset = new Phaser.Point;
this.cameraOffset = new Phaser.Point();
/**
* You can crop the Sprites texture by modifying the crop properties. For example crop.width = 50 would set the Sprite to only render 50px wide.
@@ -537,7 +559,7 @@ Phaser.Sprite.prototype.updateBounds = function() {
this.updateFrame = true;
if (this.inWorld == false)
if (this.inWorld === false)
{
// Sprite WAS out of the screen, is it still?
this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
@@ -553,7 +575,7 @@ Phaser.Sprite.prototype.updateBounds = function() {
// Sprite WAS in the screen, has it now left?
this.inWorld = Phaser.Rectangle.intersects(this.bounds, this.game.world.bounds, this.inWorldThreshold);
if (this.inWorld == false)
if (this.inWorld === false)
{
this.events.onOutOfBounds.dispatch(this);
this._outOfBoundsFired = true;
@@ -1079,7 +1101,7 @@ Object.defineProperty(Phaser.Sprite.prototype, "inputEnabled", {
if (value)
{
if (this.input.enabled == false)
if (this.input.enabled === false)
{
this.input.start();
}
+56 -38
View File
@@ -21,81 +21,99 @@ Phaser.Text = function (game, x, y, text, style) {
text = text || '';
style = style || '';
// If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all
/**
* @property {boolean} exists - Description.
* @default
*/
/**
* @property {Phaser.Game} game - A reference to the currently running Game.
*/
this.game = game;
/**
* @property {boolean} exists - If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all.
* @default
*/
this.exists = true;
// This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering
/**
* @property {boolean} alive - Description.
* @default
*/
/**
* @property {boolean} alive - This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering.
* @default
*/
this.alive = true;
/**
* @property {Description} group - Description.
* @default
*/
/**
* @property {Phaser.Group} group - The parent Group of this Sprite. This is usually set after Sprite instantiation by the parent.
*/
this.group = null;
/**
* @property {string} name - Description.
* @default
*/
/**
* @property {string} name - The user defined name given to this Sprite.
* @default
*/
this.name = '';
/**
* @property {Phaser.Game} game - A reference to the currently running game.
* @property {number} type - The const type of this object.
* @default
*/
this.game = game;
this.type = Phaser.TEXT;
/**
* @property {string} _text - Internal value.
* @private
*/
this._text = text;
/**
* @property {string} _style - Internal value.
* @private
*/
this._style = style;
PIXI.Text.call(this, text, style);
/**
* @property {Description} type - Description.
*/
this.type = Phaser.TEXT;
/**
* @property {Description} position - Description.
* @property {Phaser.Point} position - The position of this Text object in world space.
*/
this.position.x = this.x = x;
this.position.y = this.y = y;
// Replaces the PIXI.Point with a slightly more flexible one
/**
* @property {Phaser.Point} anchor - Description.
*/
* The anchor sets the origin point of the texture.
* The default is 0,0 this means the textures origin is the top left
* Setting than anchor to 0.5,0.5 means the textures origin is centered
* Setting the anchor to 1,1 would mean the textures origin points will be the bottom right
*
* @property {Phaser.Point} anchor - The anchor around with Sprite rotation and scaling takes place.
*/
this.anchor = new Phaser.Point();
/**
* @property {Phaser.Point} scale - Description.
*/
* @property {Phaser.Point} scale - The scale of the object when rendered. By default it's set to 1 (no scale). You can modify it via scale.x or scale.y or scale.setTo(x, y). A value of 1 means no change to the scale, 0.5 means "half the size", 2 means "twice the size", etc.
*/
this.scale = new Phaser.Point(1, 1);
// A mini cache for storing all of the calculated values
/**
* @property {Description} _cache - Description.
* @property {object} _cache - A mini cache for storing all of the calculated values.
* @private
*/
this._cache = {
this._cache = {
dirty: false,
// Transform cache
a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1,
a00: 1,
a01: 0,
a02: x,
a10: 0,
a11: 1,
a12: y,
id: 1,
// The previous calculated position
x: -1, y: -1,
x: -1,
y: -1,
// The actual scale values based on the worldTransform
scaleX: 1, scaleY: 1
scaleX: 1,
scaleY: 1
};
@@ -103,7 +121,7 @@ Phaser.Text = function (game, x, y, text, style) {
this._cache.y = this.y;
/**
* @property {boolean} renderable - Description.
* @property {boolean} renderable - A renderable object will be rendered to the context each frame.
*/
this.renderable = true;
+18 -17
View File
@@ -5,8 +5,9 @@
*/
/**
* Create a new <code>TileSprite</code>.
* A TileSprite is a Sprite whos texture is set to repeat and can be scrolled. As it scrolls the texture repeats (wraps) on the edges.
* @class Phaser.Tilemap
* @extends Phaser.Sprite
* @constructor
* @param {Phaser.Game} game - Current game instance.
* @param {number} x - X position of the new tileSprite.
@@ -25,33 +26,33 @@ Phaser.TileSprite = function (game, x, y, width, height, key, frame) {
key = key || null;
frame = frame || null;
Phaser.Sprite.call(this, game, x, y, key, frame);
Phaser.Sprite.call(this, game, x, y, key, frame);
/**
* @property {Description} texture - Description.
/**
* @property {PIXI.Texture} texture - The texture that the sprite renders with.
*/
this.texture = PIXI.TextureCache[key];
PIXI.TilingSprite.call(this, this.texture, width, height);
PIXI.TilingSprite.call(this, this.texture, width, height);
/**
* @property {Description} type - Description.
/**
* @property {number} type - The const type of this object.
* @readonly
*/
this.type = Phaser.TILESPRITE;
this.type = Phaser.TILESPRITE;
/**
* @property {Point} tileScale - The scaling of the image that is being tiled.
*/
this.tileScale = new Phaser.Point(1, 1);
/**
* @property {Phaser.Point} tileScale - The scaling of the image that is being tiled.
*/
this.tileScale = new Phaser.Point(1, 1);
/**
* @property {Point} tilePosition - The offset position of the image that is being tiled.
*/
this.tilePosition = new Phaser.Point(0, 0);
/**
* @property {Phaser.Point} tilePosition - The offset position of the image that is being tiled.
*/
this.tilePosition = new Phaser.Point(0, 0);
};
Phaser.TileSprite.prototype = Phaser.Utils.extend(true, PIXI.TilingSprite.prototype, Phaser.Sprite.prototype);
Phaser.TileSprite.prototype.constructor = Phaser.TileSprite;
// Add our own custom methods