Updating and fixing tests

This commit is contained in:
Richard Davey
2013-08-02 18:32:26 +01:00
parent 4c9c50584e
commit 982faeedb8
88 changed files with 571 additions and 1722 deletions
-7
View File
@@ -24,7 +24,6 @@ module Phaser {
this.input = game.input;
this.load = game.load;
this.math = game.math;
//this.motion = game.motion;
this.sound = game.sound;
this.stage = game.stage;
this.time = game.time;
@@ -74,12 +73,6 @@ module Phaser {
*/
public math: GameMath;
/**
* Reference to the motion helper.
* @type {Motion}
*/
//public motion: Motion;
/**
* Reference to the sound manager.
* @type {SoundManager}
@@ -268,7 +268,7 @@ module Phaser.Components {
public set frameName(value: string) {
if (this._frameData.getFrameByName(value))
if (this._frameData && this._frameData.getFrameByName(value))
{
this.currentFrame = this._frameData.getFrameByName(value);
@@ -277,6 +277,10 @@ module Phaser.Components {
this._frameIndex = this.currentFrame.index;
}
else
{
throw new Error("Cannot set frameName: " + value);
}
}
+2 -1
View File
@@ -241,7 +241,6 @@ module Phaser.Components.Sprite {
this._parent.events.onDragStart = new Phaser.Signal;
this._parent.events.onDragStop = new Phaser.Signal;
}
}
return this._parent;
@@ -381,6 +380,7 @@ module Phaser.Components.Sprite {
this._pointerData[pointer.id].isUp = false;
this._pointerData[pointer.id].timeDown = this.game.time.now;
//console.log('touchedHandler: ' + Date.now());
this._parent.events.onInputDown.dispatch(this._parent, pointer);
// Start drag
@@ -416,6 +416,7 @@ module Phaser.Components.Sprite {
// Only release the InputUp signal if the pointer is still over this sprite
if (SpriteUtils.overlapsXY(this._parent, pointer.worldX(), pointer.worldY()))
{
//console.log('releasedHandler: ' + Date.now());
this._parent.events.onInputUp.dispatch(this._parent, pointer);
}
else
+4
View File
@@ -161,6 +161,8 @@ module Phaser {
private onInputDownHandler(pointer:Phaser.Pointer) {
//console.log('Button onInputDownHandler: ' + Date.now());
if (this._onDownFrameName != null)
{
this.frameName = this._onDownFrameName;
@@ -179,6 +181,8 @@ module Phaser {
private onInputUpHandler(pointer:Phaser.Pointer) {
//console.log('Button onInputUpHandler: ' + Date.now());
if (this._onUpFrameName != null)
{
this.frameName = this._onUpFrameName;
+7
View File
@@ -265,6 +265,13 @@ module Phaser {
}
public add(sprite: Sprite) {
sprite.texture.canvas = this.canvas;
sprite.texture.context = this.context;
}
/**
* Given an array of Sprites it will update each of them so that their canvas/contexts reference this DynamicTexture
* @param objects {Array} An array of GameObjects, or objects that inherit from it such as Sprites
+1 -1
View File
@@ -139,7 +139,7 @@ module Phaser {
/**
* The action to be taken when the sprite is fully out of the world bounds
* Defaults to Phaser.Types.OUT_OF_BOUNDS_KILL
* Defaults to Phaser.Types.OUT_OF_BOUNDS_PERSIST
*/
public outOfBoundsAction: number;
+1 -1
View File
@@ -239,7 +239,7 @@ module Phaser {
/**
* Determines whether or not this Rectangle object is empty.
* @method isEmpty
* @return {Boolean} A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false.
* @return {Boolean} A value of true if the Rectangle objects width or height is less than or equal to 0; otherwise false.
**/
get empty(): bool {
return (!this.width || !this.height);
+6
View File
@@ -50,6 +50,12 @@ module Phaser {
*/
public start() {
if (this._game.device.android && this._game.device.chrome == false)
{
// Android stock browser fires mouse events even if you preventDefault on the touchStart, so ...
return;
}
this._game.stage.canvas.addEventListener('mousedown', (event: MouseEvent) => this.onMouseDown(event), true);
this._game.stage.canvas.addEventListener('mousemove', (event: MouseEvent) => this.onMouseMove(event), true);
this._game.stage.canvas.addEventListener('mouseup', (event: MouseEvent) => this.onMouseUp(event), true);
+4
View File
@@ -413,6 +413,8 @@ module Phaser {
this._fileList[key].loaded = true;
this._fileList[key].error = true;
throw new Error("Phaser.Loader error loading file: " + key);
this.nextFile(key, false);
}
@@ -531,6 +533,8 @@ module Phaser {
file.error = true;
throw new Error("Phaser.Loader dataLoadError: " + key);
this.nextFile(key, true);
}
+1 -1
View File
@@ -32,7 +32,7 @@ module Phaser.Physics {
}
/**
* Local private reference to Game.
* Local reference to Game.
*/
public game: Game;
+35 -27
View File
@@ -458,11 +458,6 @@ module Phaser {
return false;
}
if (sprite.crop && sprite.crop.empty)
{
return;
}
sprite.renderOrderID = this._count;
this._count++;
@@ -478,20 +473,6 @@ module Phaser {
this._dw = sprite.texture.width;
this._dh = sprite.texture.height;
// Global Composite Ops
if (sprite.texture.globalCompositeOperation)
{
sprite.texture.context.save();
sprite.texture.context.globalCompositeOperation = sprite.texture.globalCompositeOperation;
}
// Alpha
if (sprite.texture.alpha !== 1 && sprite.texture.context.globalAlpha != sprite.texture.alpha)
{
this._ga = sprite.texture.context.globalAlpha;
sprite.texture.context.globalAlpha = sprite.texture.alpha;
}
if (sprite.animations.currentFrame !== null)
{
this._sx = sprite.animations.currentFrame.x;
@@ -540,16 +521,43 @@ module Phaser {
this._dy += sprite.crop.y * sprite.transform.scale.y;
this._dw = sprite.crop.width * sprite.transform.scale.x;
this._dh = sprite.crop.height * sprite.transform.scale.y;
//this._sx += sprite.crop.x;
//this._sy += sprite.crop.y;
//this._sw = sprite.crop.width;
//this._sh = sprite.crop.height;
//this._dx += sprite.crop.x;
//this._dy += sprite.crop.y;
//this._dw = sprite.crop.width;
//this._dh = sprite.crop.height;
}
this._sx = Math.round(this._sx);
this._sy = Math.round(this._sy);
this._sw = Math.round(this._sw);
this._sh = Math.round(this._sh);
this._dx = Math.round(this._dx);
this._dy = Math.round(this._dy);
this._dw = Math.round(this._dw);
this._dh = Math.round(this._dh);
this._sx = Math.floor(this._sx);
this._sy = Math.floor(this._sy);
this._sw = Math.floor(this._sw);
this._sh = Math.floor(this._sh);
this._dx = Math.floor(this._dx);
this._dy = Math.floor(this._dy);
this._dw = Math.floor(this._dw);
this._dh = Math.floor(this._dh);
if (this._sw <= 0 || this._sh <= 0 || this._dw <= 0 || this._dh <= 0)
{
return false;
}
// Global Composite Ops
if (sprite.texture.globalCompositeOperation)
{
sprite.texture.context.save();
sprite.texture.context.globalCompositeOperation = sprite.texture.globalCompositeOperation;
}
// Alpha
if (sprite.texture.alpha !== 1 && sprite.texture.context.globalAlpha != sprite.texture.alpha)
{
this._ga = sprite.texture.context.globalAlpha;
sprite.texture.context.globalAlpha = sprite.texture.alpha;
}
if (sprite.texture.opaque)
{