New examples page

This commit is contained in:
photonstorm
2013-10-18 15:12:32 +01:00
parent dabda516c2
commit 8ed783802e
11 changed files with 209 additions and 65 deletions
+21 -2
View File
@@ -36,6 +36,12 @@ Phaser.AnimationManager = function (sprite) {
*/
this.updateIfVisible = true;
/**
* @property {boolean} isLoaded - Set to true once animation data has been loaded.
* @default
*/
this.isLoaded = false;
/**
* @property {Phaser.FrameData} _frameData - A temp. var for holding the currently playing Animations FrameData.
* @private
@@ -71,6 +77,7 @@ Phaser.AnimationManager.prototype = {
this._frameData = frameData;
this.frame = 0;
this.isLoaded = true;
},
@@ -252,6 +259,18 @@ Phaser.AnimationManager.prototype = {
},
/**
* Refreshes the current frame data back to the parent Sprite and also resets the texture data.
*
* @method Phaser.AnimationManager#refreshFrame
*/
refreshFrame: function () {
this.sprite.currentFrame = this.currentFrame;
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
},
/**
* Destroys all references this AnimationManager contains. Sets the _anims to a new object and nulls the current animation.
*
@@ -340,7 +359,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
set: function (value) {
if (this._frameData && this._frameData.getFrame(value) !== null)
if (typeof value === 'number' && this._frameData && this._frameData.getFrame(value) !== null)
{
this.currentFrame = this._frameData.getFrame(value);
this._frameIndex = value;
@@ -369,7 +388,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
set: function (value) {
if (this._frameData && this._frameData.getFrameByName(value) !== null)
if (typeof value === 'string' && this._frameData && this._frameData.getFrameByName(value) !== null)
{
this.currentFrame = this._frameData.getFrameByName(value);
this._frameIndex = this.currentFrame.index;
+2 -1
View File
@@ -29,8 +29,9 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
renderer = renderer || Phaser.AUTO;
parent = parent || '';
state = state || null;
if (typeof transparent == 'undefined') { transparent = false; }
if (typeof antialias == 'undefined') { antialias = false; }
if (typeof antialias == 'undefined') { antialias = true; }
/**
* @property {number} id - Phaser Game ID (for when Pixi supports multiple instances).
+12
View File
@@ -880,7 +880,19 @@ Object.defineProperty(Phaser.Sprite.prototype, "crop", {
this._cropRect = value;
this.setTexture(PIXI.TextureCache[this._cropUUID]);
}
else
{
this._cropRect = null;
if (this.animations.isLoaded)
{
this.animations.refreshFrame();
}
else
{
this.setTexture(PIXI.TextureCache[this.key]);
}
}
}
});
+10 -6
View File
@@ -112,8 +112,12 @@ Phaser.Physics.Arcade.Body.prototype = {
this.screenX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
this.screenY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.preX = (this.sprite.localTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
this.preY = (this.sprite.localTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
// this.preX = (this.sprite.localTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
// this.preY = (this.sprite.localTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.preRotation = this.sprite.angle;
this.x = this.preX;
@@ -237,10 +241,10 @@ Phaser.Physics.Arcade.Body.prototype = {
this.angularVelocity = 0;
this.angularAcceleration = 0;
// this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
// this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.preX = (this.sprite.localTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
this.preY = (this.sprite.localTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.preX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
this.preY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
// this.preX = (this.sprite.localTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
// this.preY = (this.sprite.localTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.preRotation = this.sprite.angle;
this.x = this.preX;
+1
View File
@@ -21,6 +21,7 @@ Phaser.Canvas = {
* @return {HTMLCanvasElement} The newly created <canvas> tag.
*/
create: function (width, height) {
width = width || 256;
height = height || 256;