Merged N+ physics in and tidied up the Docs folder and logos.

This commit is contained in:
Richard Davey
2013-08-11 12:15:53 +01:00
parent aff7d99a8a
commit c2d7fb7fab
108 changed files with 17900 additions and 2017 deletions
+22 -15
View File
@@ -84,6 +84,19 @@ var Phaser;
return this.game.sound.add(key, volume, loop);
};
GameObjectFactory.prototype.circle = function (x, y, radius) {
return new Phaser.Physics.Circle(this.game, x, y, radius);
};
GameObjectFactory.prototype.aabb = function (x, y, width, height) {
return new Phaser.Physics.AABB(this.game, x, y, Math.floor(width / 2), Math.floor(height / 2));
};
GameObjectFactory.prototype.cell = function (x, y, width, height, state) {
if (typeof state === "undefined") { state = Phaser.Physics.TileMapCell.TID_FULL; }
return new Phaser.Physics.TileMapCell(this.game, x, y, width, height).SetState(state);
};
/**
* Create a new Sprite with the physics automatically created and set to DYNAMIC. The Sprite position offset is set to its center.
*
@@ -125,10 +138,9 @@ var Phaser;
*
* @return {Particle} The newly created particle object.
*/
GameObjectFactory.prototype.particle = function () {
return new Phaser.ArcadeParticle(this.game);
};
//public particle(): Phaser.ArcadeParticle {
// return new Phaser.ArcadeParticle(this.game);
//}
/**
* Create a new Emitter.
*
@@ -137,13 +149,9 @@ var Phaser;
* @param size {number} Optional, size of this emitter.
* @return {Emitter} The newly created emitter object.
*/
GameObjectFactory.prototype.emitter = function (x, y, size) {
if (typeof x === "undefined") { x = 0; }
if (typeof y === "undefined") { y = 0; }
if (typeof size === "undefined") { size = 0; }
return this._world.group.add(new Phaser.ArcadeEmitter(this.game, x, y, size));
};
//public emitter(x: number = 0, y: number = 0, size: number = 0): Phaser.ArcadeEmitter {
// return <Phaser.ArcadeEmitter> this._world.group.add(new Phaser.ArcadeEmitter(this.game, x, y, size));
//}
/**
* Create a new ScrollZone object with image key, position and size.
*
@@ -242,10 +250,9 @@ var Phaser;
* @param emitter The Emitter to add to the Game World
* @return {Phaser.Emitter} The Emitter object
*/
GameObjectFactory.prototype.existingEmitter = function (emitter) {
return this._world.group.add(emitter);
};
//public existingEmitter(emitter: Phaser.ArcadeEmitter): Phaser.ArcadeEmitter {
// return this._world.group.add(emitter);
//}
/**
* Add an existing ScrollZone to the current world.
* Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
+21 -9
View File
@@ -89,6 +89,18 @@ module Phaser {
return <Phaser.Sound> this.game.sound.add(key, volume, loop);
}
public circle(x: number, y: number, radius: number): Phaser.Physics.Circle {
return new Phaser.Physics.Circle(this.game, x, y, radius);
}
public aabb(x: number, y: number, width: number, height:number): Phaser.Physics.AABB {
return new Phaser.Physics.AABB(this.game, x, y, Math.floor(width / 2), Math.floor(height / 2));
}
public cell(x: number, y: number, width: number, height: number, state: number = Phaser.Physics.TileMapCell.TID_FULL): Phaser.Physics.TileMapCell {
return new Phaser.Physics.TileMapCell(this.game, x, y, width, height).SetState(state);
}
/**
* Create a new Sprite with the physics automatically created and set to DYNAMIC. The Sprite position offset is set to its center.
*
@@ -130,9 +142,9 @@ module Phaser {
*
* @return {Particle} The newly created particle object.
*/
public particle(): Phaser.ArcadeParticle {
return new Phaser.ArcadeParticle(this.game);
}
//public particle(): Phaser.ArcadeParticle {
// return new Phaser.ArcadeParticle(this.game);
//}
/**
* Create a new Emitter.
@@ -142,9 +154,9 @@ module Phaser {
* @param size {number} Optional, size of this emitter.
* @return {Emitter} The newly created emitter object.
*/
public emitter(x: number = 0, y: number = 0, size: number = 0): Phaser.ArcadeEmitter {
return <Phaser.ArcadeEmitter> this._world.group.add(new Phaser.ArcadeEmitter(this.game, x, y, size));
}
//public emitter(x: number = 0, y: number = 0, size: number = 0): Phaser.ArcadeEmitter {
// return <Phaser.ArcadeEmitter> this._world.group.add(new Phaser.ArcadeEmitter(this.game, x, y, size));
//}
/**
* Create a new ScrollZone object with image key, position and size.
@@ -237,9 +249,9 @@ module Phaser {
* @param emitter The Emitter to add to the Game World
* @return {Phaser.Emitter} The Emitter object
*/
public existingEmitter(emitter: Phaser.ArcadeEmitter): Phaser.ArcadeEmitter {
return this._world.group.add(emitter);
}
//public existingEmitter(emitter: Phaser.ArcadeEmitter): Phaser.ArcadeEmitter {
// return this._world.group.add(emitter);
//}
/**
* Add an existing ScrollZone to the current world.
+30 -24
View File
@@ -144,8 +144,7 @@ var Phaser;
TransformManager.prototype.centerOn = function (x, y) {
this.parent.x = x + (this.parent.x - this.center.x);
this.parent.y = y + (this.parent.y - this.center.y);
this.setCache();
//this.setCache();
};
/**
@@ -164,10 +163,8 @@ var Phaser;
this._size.y = this.parent.height;
this._origin.x = this.origin.x;
this._origin.y = this.origin.y;
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._scA.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._prevRotation = this.rotation;
if (this.parent.texture && this.parent.texture.renderRotation) {
@@ -188,6 +185,9 @@ var Phaser;
this._pos.x = this.parent.x;
this._pos.y = this.parent.y;
this._flippedX = this.parent.texture.flippedX;
this._flippedY = this.parent.texture.flippedY;
};
/**
@@ -213,9 +213,7 @@ var Phaser;
this._dirty = true;
}
if (this.rotation != this._prevRotation) {
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
if (this.rotation != this._prevRotation || this._dirty) {
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._scA.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
@@ -243,27 +241,35 @@ var Phaser;
this._pos.x = this.parent.x;
this._pos.y = this.parent.y;
// Translate
this.local.data[2] = this.parent.x;
this.local.data[5] = this.parent.y;
}
if (this.parent.texture.flippedX) {
this.local.data[0] = this._sc.y * -this.scale.x;
this.local.data[3] = (this._sc.x * -this.scale.x) + this.skew.x;
} else {
this.local.data[0] = this._sc.y * this.scale.x;
this.local.data[3] = (this._sc.x * this.scale.x) + this.skew.x;
if (this._dirty || this._flippedX != this.parent.texture.flippedX) {
this._flippedX = this.parent.texture.flippedX;
if (this._flippedX) {
this.local.data[0] = this._sc.y * -this.scale.x;
this.local.data[3] = (this._sc.x * -this.scale.x) + this.skew.x;
} else {
this.local.data[0] = this._sc.y * this.scale.x;
this.local.data[3] = (this._sc.x * this.scale.x) + this.skew.x;
}
}
if (this.parent.texture.flippedY) {
this.local.data[4] = this._sc.y * -this.scale.y;
this.local.data[1] = -(this._sc.x * -this.scale.y) + this.skew.y;
} else {
this.local.data[4] = this._sc.y * this.scale.y;
this.local.data[1] = -(this._sc.x * this.scale.y) + this.skew.y;
}
if (this._dirty || this._flippedY != this.parent.texture.flippedY) {
this._flippedY = this.parent.texture.flippedY;
// Translate
this.local.data[2] = this.parent.x;
this.local.data[5] = this.parent.y;
if (this._flippedY) {
this.local.data[4] = this._sc.y * -this.scale.y;
this.local.data[1] = -(this._sc.x * -this.scale.y) + this.skew.y;
} else {
this.local.data[4] = this._sc.y * this.scale.y;
this.local.data[1] = -(this._sc.x * this.scale.y) + this.skew.y;
}
}
};
return TransformManager;
})();
+39 -28
View File
@@ -57,6 +57,8 @@ module Phaser.Components {
private _angle: number;
private _distance: number;
private _prevRotation: number;
private _flippedX: boolean;
private _flippedY: boolean;
/**
* Reference to Phaser.Game
@@ -197,7 +199,7 @@ module Phaser.Components {
this.parent.x = x + (this.parent.x - this.center.x);
this.parent.y = y + (this.parent.y - this.center.y);
this.setCache();
//this.setCache();
}
@@ -218,10 +220,8 @@ module Phaser.Components {
this._size.y = this.parent.height;
this._origin.x = this.origin.x;
this._origin.y = this.origin.y;
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._scA.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._prevRotation = this.rotation;
if (this.parent.texture && this.parent.texture.renderRotation)
@@ -246,6 +246,9 @@ module Phaser.Components {
this._pos.x = this.parent.x;
this._pos.y = this.parent.y;
this._flippedX = this.parent.texture.flippedX;
this._flippedY = this.parent.texture.flippedY;
}
/**
@@ -274,10 +277,8 @@ module Phaser.Components {
}
// 2) Rotation change
if (this.rotation != this._prevRotation)
if (this.rotation != this._prevRotation || this._dirty)
{
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._scA.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
@@ -297,7 +298,7 @@ module Phaser.Components {
this._dirty = true;
}
// If it has moved, update the edges and center
// 3) If it has moved (or any of the above) then update the edges and center
if (this._dirty || this.parent.x != this._pos.x || this.parent.y != this._pos.y)
{
this.center.x = this.parent.x + this._distance * this._scA.y;
@@ -310,34 +311,44 @@ module Phaser.Components {
this._pos.x = this.parent.x;
this._pos.y = this.parent.y;
// Translate
this.local.data[2] = this.parent.x;
this.local.data[5] = this.parent.y;
}
// Scale and Skew
if (this.parent.texture.flippedX)
if (this._dirty || this._flippedX != this.parent.texture.flippedX)
{
this.local.data[0] = this._sc.y * -this.scale.x;
this.local.data[3] = (this._sc.x * -this.scale.x) + this.skew.x;
}
else
{
this.local.data[0] = this._sc.y * this.scale.x;
this.local.data[3] = (this._sc.x * this.scale.x) + this.skew.x;
this._flippedX = this.parent.texture.flippedX;
if (this._flippedX)
{
this.local.data[0] = this._sc.y * -this.scale.x;
this.local.data[3] = (this._sc.x * -this.scale.x) + this.skew.x;
}
else
{
this.local.data[0] = this._sc.y * this.scale.x;
this.local.data[3] = (this._sc.x * this.scale.x) + this.skew.x;
}
}
if (this.parent.texture.flippedY)
if (this._dirty || this._flippedY != this.parent.texture.flippedY)
{
this.local.data[4] = this._sc.y * -this.scale.y;
this.local.data[1] = -(this._sc.x * -this.scale.y) + this.skew.y;
}
else
{
this.local.data[4] = this._sc.y * this.scale.y;
this.local.data[1] = -(this._sc.x * this.scale.y) + this.skew.y;
}
this._flippedY = this.parent.texture.flippedY;
// Translate
this.local.data[2] = this.parent.x;
this.local.data[5] = this.parent.y;
if (this._flippedY)
{
this.local.data[4] = this._sc.y * -this.scale.y;
this.local.data[1] = -(this._sc.x * -this.scale.y) + this.skew.y;
}
else
{
this.local.data[4] = this._sc.y * this.scale.y;
this.local.data[1] = -(this._sc.x * this.scale.y) + this.skew.y;
}
}
}