Skip to content

Commit

Permalink
Updating and fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
photonstorm committed Aug 2, 2013
1 parent 4c9c505 commit 982faee
Show file tree
Hide file tree
Showing 88 changed files with 571 additions and 1,722 deletions.
7 changes: 0 additions & 7 deletions Phaser/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}
Expand Down
6 changes: 5 additions & 1 deletion Phaser/components/animation/AnimationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -277,6 +277,10 @@ module Phaser.Components {

this._frameIndex = this.currentFrame.index;
}
else
{
throw new Error("Cannot set frameName: " + value);
}

}

Expand Down
3 changes: 2 additions & 1 deletion Phaser/components/sprite/Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Phaser/gameobjects/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions Phaser/gameobjects/DynamicTexture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Phaser/gameobjects/Sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion Phaser/geom/Rectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions Phaser/input/Mouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions Phaser/loader/Loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Expand Down Expand Up @@ -531,6 +533,8 @@ module Phaser {

file.error = true;

throw new Error("Phaser.Loader dataLoadError: " + key);

this.nextFile(key, true);

}
Expand Down
2 changes: 1 addition & 1 deletion Phaser/physics/arcade/ArcadePhysics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module Phaser.Physics {
}

/**
* Local private reference to Game.
* Local reference to Game.
*/
public game: Game;

Expand Down
62 changes: 35 additions & 27 deletions Phaser/renderers/CanvasRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,6 @@ module Phaser {
return false;
}

if (sprite.crop && sprite.crop.empty)
{
return;
}

sprite.renderOrderID = this._count;

this._count++;
Expand All @@ -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;
Expand Down Expand Up @@ -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.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;
}

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);
// 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)
{
Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,10 @@ TODO:
* Dispatch world resize event
* Investigate why tweens don't restart after the game pauses
* Fix bug in Tween yoyo + loop combo
* Apply Sprite scaling to Body.bounds
* Check that tween pausing works with the new performance.now
* Game.Time should monitor pause duration
* Investigate bug re: tilemap collision and animation frames
* Update tests that use arrow keys and include touch/mouse support (FlxControlHandler style)
* Texture Repeat doesn't scroll, because it's part of the camera not the world, need to think about this more
* Add JSON Texture Atlas object support.
* Pointer.getWorldX(camera) needs to take camera scale into consideration
* If stage.clear set to false and game pauses, when it unpauses you still see the pause arrow - resolve this
* Add clip support + shape options to Texture Component.
Expand All @@ -44,11 +41,7 @@ TODO:
* See which functions in the input component can move elsewhere (utils)
* Move all of the renderDebugInfo methods to the DebugUtils class
* Check bounds/edge points when sprite is only 1x1 sized :)
* See what I can move out of Body and into a BodyUtils class.
* See about optimising Advanced Physics a lot more, so it doesn't create lots of Vec2s everywhere.
* QuadTree.physics.checkHullIntersection
* Fix the Motion methods for the new physics system
* Move findShapeByPoint etc from Space to Manager (or at least add a proxy to them)
* Add visible toggle if tween property is alpha <> 01
* Camera.isHidden uses an array and length check, faster to swap for a single counter, also try to remove indexOf check
* Tilemap.render - move layers length to var
Expand All @@ -69,6 +62,7 @@ TODO:
* Pixel-perfect click check
* Check Flash atlas export is supported
* Plug-in Support
* DynamicTexture.setPixel needs to be swapped for a proper pixel put, not the filledRect it currently is.



Expand Down
Loading

0 comments on commit 982faee

Please sign in to comment.