Updated DynamicTexture.setPixel, added GameMath.shuffleArray, fixed Animation.frame and created a few new tests

This commit is contained in:
Richard Davey
2013-05-18 03:05:28 +01:00
parent 55568592b5
commit 53aa43566e
21 changed files with 529 additions and 95 deletions
+21
View File
@@ -470,6 +470,27 @@ module Phaser {
}
public isConsoleOpen(): bool {
if (window.console && window.console['firebug'])
{
return true;
}
if (window.console)
{
console.profile();
console.profileEnd();
if (console.clear) console.clear();
return console['profiles'].length > 0;
}
return false;
}
/**
* Get all informations of host device.
* @return {string} Informations in a string.
+10 -4
View File
@@ -114,14 +114,15 @@ module Phaser {
public onComplete: Phaser.Signal;
/**
* Config the tween result.
* Configure the Tween
* @param properties {object} Propertis you want to tween.
* @param [duration] {number} duration of this tween.
* @param ease {any} Easing function.
* @param autoStart {boolean} Whether this tween will start automatically or not.
* @param [ease] {any} Easing function.
* @param [autoStart] {boolean} Whether this tween will start automatically or not.
* @param [delay] {number} delay before this tween will start, defaults to 0 (no delay)
* @return {Tween} Itself.
*/
public to(properties, duration?: number = 1000, ease?: any = null, autoStart?: bool = false) {
public to(properties, duration?: number = 1000, ease?: any = null, autoStart?: bool = false, delay?:number = 0) {
this._duration = duration;
@@ -133,6 +134,11 @@ module Phaser {
this._easingFunction = ease;
}
if (delay > 0)
{
this._delayTime = delay;
}
if (autoStart === true)
{
return this.start();
+19 -1
View File
@@ -44,21 +44,25 @@ module Phaser {
* Local private reference to game.
*/
private _game: Game;
/**
* Local private reference to its owner sprite.
* @type {Sprite}
*/
private _parent: Sprite;
/**
* Animation frame container.
* @type {number[]}
*/
private _frames: number[];
/**
* Frame data of this animation.(parsed from sprite sheet)
* @type {FrameData}
*/
private _frameData: FrameData;
/**
* Index of current frame.
* @type {number}
@@ -70,6 +74,7 @@ module Phaser {
* @type number
*/
private _timeLastFrame: number;
/**
* Time when this will switch to next frame (in ms).
* @type number
@@ -81,6 +86,7 @@ module Phaser {
* @type {string}
*/
public name: string;
/**
* Currently played frame instance.
* @type {Frame}
@@ -92,16 +98,19 @@ module Phaser {
* @type {boolean}
*/
public isFinished: bool;
/**
* Whethor or not this animation is currently playing.
* @type {boolean}
*/
public isPlaying: bool;
/**
* Whether or not the animation is looped.
* @type {boolean}
*/
public looped: bool;
/**
* Time between frames in ms.
* @type {number}
@@ -113,7 +122,16 @@ module Phaser {
}
public get frame(): number {
return this._frameIndex;
if (this.currentFrame !== null)
{
return this.currentFrame.index;
}
else
{
return this._frameIndex;
}
}
public set frame(value: number) {
+33 -6
View File
@@ -42,6 +42,9 @@ module Phaser {
this.onTap = new Phaser.Signal();
this.onHold = new Phaser.Signal();
this.point = new Point();
this.circle = new Circle(0, 0, 44);
this.currentPointers = 0;
}
@@ -111,6 +114,21 @@ module Phaser {
*/
public gestures: Gestures;
/**
* A Point object representing the x/y screen coordinates of the Pointer.
* @property point
* @type {Point}
**/
public point: Point = null;
/**
* A Circle object centered on the x/y screen coordinates of the Input.
* Default size of 44px (Apples recommended "finger tip" size) but can be changed to anything
* @property circle
* @type {Circle}
**/
public circle: Circle = null;
/**
* X coordinate of the most recent Pointer event
* @type {Number}
@@ -371,7 +389,12 @@ module Phaser {
}
public reset() {
/**
* Reset all of the Pointers and Input states
* @method reset
* @param hard {Boolean} A soft reset (hard = false) won't reset any signals that might be bound. A hard reset will.
**/
public reset(hard?: bool = false) {
this.keyboard.reset();
@@ -386,13 +409,17 @@ module Phaser {
this.pointer9.reset();
this.pointer10.reset();
this.onDown = new Phaser.Signal();
this.onUp = new Phaser.Signal();
this.onTap = new Phaser.Signal();
this.onHold = new Phaser.Signal();
this.currentPointers = 0;
if (hard == true)
{
this.onDown = new Phaser.Signal();
this.onUp = new Phaser.Signal();
this.onTap = new Phaser.Signal();
this.onHold = new Phaser.Signal();
}
}
/**
+8 -4
View File
@@ -370,12 +370,16 @@ module Phaser {
this.y = this.pageY - this._game.stage.offset.y;
this.pointB.setTo(this.x, this.y);
this.circle.setTo(this.x, this.y, 44);
this.circle.x = this.x;
this.circle.y = this.y;
if (this._game.input.multiInputOverride == Input.MOUSE_OVERRIDES_TOUCH || this._game.input.multiInputOverride == Input.MOUSE_TOUCH_COMBINE || (this._game.input.multiInputOverride == Input.TOUCH_OVERRIDES_MOUSE && this._game.input.currentPointers == 0))
{
this._game.input.x = this.x * this._game.input.scaleX;
this._game.input.y = this.y * this._game.input.scaleY;
this._game.input.point.setTo(this._game.input.x, this._game.input.y);
this._game.input.circle.x = this._game.input.x;
this._game.input.circle.y = this._game.input.y;
}
return this;
@@ -507,16 +511,16 @@ module Phaser {
}
this._game.stage.context.beginPath();
this._game.stage.context.arc(this.x, this.y, this.circle.radius * 2, 0, Math.PI * 2);
this._game.stage.context.arc(this.x, this.y, this.circle.radius, 0, Math.PI * 2);
if (this.active)
{
this._game.stage.context.fillStyle = 'rgb(0,255,0)';
this._game.stage.context.fillStyle = 'rgba(0,255,0,0.5)';
this._game.stage.context.strokeStyle = 'rgb(0,255,0)';
}
else
{
this._game.stage.context.fillStyle = 'rgb(100,0,0)';
this._game.stage.context.fillStyle = 'rgba(255,0,0,0.5)';
this._game.stage.context.strokeStyle = 'rgb(100,0,0)';
}