diff --git a/Phaser/AnimationManager.ts b/Phaser/AnimationManager.ts
index a84a1471..95e9a054 100644
--- a/Phaser/AnimationManager.ts
+++ b/Phaser/AnimationManager.ts
@@ -5,6 +5,13 @@
///
///
+/**
+* Phaser - AnimationManager
+*
+* Any Sprite that has animation contains an instance of the AnimationManager, which is used to add, play and update
+* sprite specific animations.
+*/
+
module Phaser {
export class AnimationManager {
diff --git a/Phaser/Basic.ts b/Phaser/Basic.ts
index 54535b2d..a850f261 100644
--- a/Phaser/Basic.ts
+++ b/Phaser/Basic.ts
@@ -1,16 +1,10 @@
///
/**
- * This is a useful "generic" object.
- * Both GameObject and Group extend this class,
- * as do the plugins. Has no size, position or graphical data.
- *
- * @author Adam Atomic
- * @author Richard Davey
- */
-
-/**
-* Phaser
+* Phaser - Basic
+*
+* A useful "generic" object on which all GameObjects and Groups are based.
+* It has no size, position or graphical data.
*/
module Phaser {
diff --git a/Phaser/Cache.ts b/Phaser/Cache.ts
index 13cbd714..2a725c8c 100644
--- a/Phaser/Cache.ts
+++ b/Phaser/Cache.ts
@@ -1,7 +1,10 @@
///
/**
-* Phaser
+* Phaser - Cache
+*
+* A game only has one instance of a Cache and it is used to store all externally loaded assets such
+* as images, sounds and data files as a result of Loader calls. Cache items use string based keys for look-up.
*/
module Phaser {
diff --git a/Phaser/CameraManager.ts b/Phaser/CameraManager.ts
index 4bc8f3e7..b4366a8d 100644
--- a/Phaser/CameraManager.ts
+++ b/Phaser/CameraManager.ts
@@ -1,11 +1,14 @@
///
///
-// TODO: If the Camera is larger than the Stage size then the rotation offset isn't correct
-// TODO: Texture Repeat doesn't scroll, because it's part of the camera not the world, need to think about this more
-
/**
-* Phaser
+* Phaser - CameraManager
+*
+* Your game only has one CameraManager instance and it's responsible for looking after, creating and destroying
+* all of the cameras in the world.
+*
+* TODO: If the Camera is larger than the Stage size then the rotation offset isn't correct
+* TODO: Texture Repeat doesn't scroll, because it's part of the camera not the world, need to think about this more
*/
module Phaser {
diff --git a/Phaser/Collision.ts b/Phaser/Collision.ts
index 09191045..aac18b85 100644
--- a/Phaser/Collision.ts
+++ b/Phaser/Collision.ts
@@ -7,7 +7,9 @@
///
/**
-* Phaser - Collision
+* Phaser - Collision
+*
+* A set of extremely useful collision and geometry intersection functions.
*/
module Phaser {
diff --git a/Phaser/DynamicTexture.ts b/Phaser/DynamicTexture.ts
index c3cff62d..53181516 100644
--- a/Phaser/DynamicTexture.ts
+++ b/Phaser/DynamicTexture.ts
@@ -1,7 +1,12 @@
///
/**
-* Phaser
+* Phaser - DynamicTexture
+*
+* A DynamicTexture can be thought of as a mini canvas into which you can draw anything.
+* Game Objects can be assigned a DynamicTexture, so when they render in the world they do so
+* based on the contents of the texture at the time. This allows you to create powerful effects
+* once and have them replicated across as many game objects as you like.
*/
module Phaser {
diff --git a/Phaser/Game.ts b/Phaser/Game.ts
index cacef060..9e679c52 100644
--- a/Phaser/Game.ts
+++ b/Phaser/Game.ts
@@ -10,7 +10,7 @@
///
///
///
-///
+///
///
///
///
@@ -30,10 +30,10 @@
///
/**
-* Phaser
+* Phaser - Game
*
-* Richard Davey (@photonstorm)
-* Adam Saltsman (@ADAMATOMIC) (original Flixel code)
+* This is where the magic happens. The Game object is the heart of your game, providing quick access to common
+* functions and handling the boot process.
*/
module Phaser {
diff --git a/Phaser/GameMath.ts b/Phaser/GameMath.ts
index 16df2713..7a285c4a 100644
--- a/Phaser/GameMath.ts
+++ b/Phaser/GameMath.ts
@@ -1,14 +1,11 @@
///
/**
- * Phaser - GameMath
- *
- * @desc Adds a set of extra Math functions and extends a few commonly used ones.
- * Includes methods written by Dylan Engelman and Adam Saltsman.
- *
- * @version 1.0 - 17th March 2013
- * @author Richard Davey
- */
+* Phaser - GameMath
+*
+* Adds a set of extra Math functions used through-out Phaser.
+* Includes methods written by Dylan Engelman and Adam Saltsman.
+*/
module Phaser {
diff --git a/Phaser/Group.ts b/Phaser/Group.ts
index 993f75d9..37c91068 100644
--- a/Phaser/Group.ts
+++ b/Phaser/Group.ts
@@ -2,16 +2,10 @@
///
/**
-* This is an organizational class that can update and render a bunch of Basics.
-* NOTE: Although Group extends Basic, it will not automatically
-* add itself to the global collisions quad tree, it will only add its members.
-*
-* @author Adam Atomic
-* @author Richard Davey
-*/
-
-/**
-* Phaser
+* Phaser - Group
+*
+* This class is used for organising, updating and sorting game objects.
+*
*/
module Phaser {
diff --git a/Phaser/Loader.ts b/Phaser/Loader.ts
index 4f5823fc..da02c0ee 100644
--- a/Phaser/Loader.ts
+++ b/Phaser/Loader.ts
@@ -1,7 +1,10 @@
///
/**
-* Phaser
+* Phaser - Loader
+*
+* The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files.
+* It uses a combination of Image() loading and xhr and provides for progress and completion callbacks.
*/
module Phaser {
diff --git a/Phaser/Motion.ts b/Phaser/Motion.ts
index 68bc6494..4a76923b 100644
--- a/Phaser/Motion.ts
+++ b/Phaser/Motion.ts
@@ -2,7 +2,9 @@
///
/**
- * Phaser - Motion
+* Phaser - Motion
+*
+* The Motion class contains lots of useful functions for moving game objects around in world space.
*/
module Phaser {
diff --git a/Phaser/Phaser.csproj b/Phaser/Phaser.csproj
index 305314ad..24faf08a 100644
--- a/Phaser/Phaser.csproj
+++ b/Phaser/Phaser.csproj
@@ -106,6 +106,14 @@
Rectangle.ts
+
+ SoundManager.ts
+
+
+ Sound.ts
+
+
+
Animation.ts
@@ -255,9 +263,6 @@
SignalBinding.ts
-
- Sound.ts
-
Stage.ts
@@ -278,7 +283,6 @@
-
diff --git a/Phaser/Phaser.ts b/Phaser/Phaser.ts
index 6b40f2c4..6236d1c6 100644
--- a/Phaser/Phaser.ts
+++ b/Phaser/Phaser.ts
@@ -1,16 +1,17 @@
/**
-* Phaser
+* Phaser
*
-* v0.9 - April 18th 2013
+* v0.9 - April 18th 2013
*
-* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
+* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
*
-* Richard Davey (@photonstorm)
-* Adam Saltsman (@ADAMATOMIC) (original Flixel code)
+* Richard Davey (@photonstorm)
*
-* "If you want your children to be intelligent, read them fairy tales."
-* "If you want them to be more intelligent, read them more fairy tales."
-* -- Albert Einstein
+* Many thanks to Adam Saltsman (@ADAMATOMIC) for the original Flixel AS3 code on which Phaser is based.
+*
+* "If you want your children to be intelligent, read them fairy tales."
+* "If you want them to be more intelligent, read them more fairy tales."
+* -- Albert Einstein
*/
module Phaser {
diff --git a/Phaser/Signal.ts b/Phaser/Signal.ts
index 832692ac..088d6b98 100644
--- a/Phaser/Signal.ts
+++ b/Phaser/Signal.ts
@@ -1,29 +1,12 @@
///
-/*
- * Signal
- *
- * @desc A TypeScript conversion of JS Signals by Miller Medeiros
- * Released under the MIT license
- * http://millermedeiros.github.com/js-signals/
- *
- * @version 1. - 7th March 2013
- *
- * @author Richard Davey, TypeScript conversion
- * @author Miller Medeiros, JS Signals
- *
-*/
-
/**
-* Custom event broadcaster
-*
- inspired by Robert Penner's AS3 Signals.
-* @name Signal
-* @author Miller Medeiros
-* @constructor
-*/
-
-/**
-* Phaser
+* Phaser - Signal
+*
+* A Signal is used for object communication via a custom broadcaster instead of Events.
+* Based on JS Signals by Miller Medeiros. Converted by TypeScript by Richard Davey.
+* Released under the MIT license
+* http://millermedeiros.github.com/js-signals/
*/
module Phaser {
diff --git a/Phaser/SignalBinding.ts b/Phaser/SignalBinding.ts
index eb616566..8e6909ca 100644
--- a/Phaser/SignalBinding.ts
+++ b/Phaser/SignalBinding.ts
@@ -1,21 +1,12 @@
///
-/*
- * SignalBinding
- *
- * @desc An object that represents a binding between a Signal and a listener function.
- * Released under the MIT license
- * http://millermedeiros.github.com/js-signals/
- *
- * @version 1. - 7th March 2013
- *
- * @author Richard Davey, TypeScript conversion
- * @author Miller Medeiros, JS Signals
- *
-*/
-
/**
-* Phaser
+* Phaser - SignalBinding
+*
+* An object that represents a binding between a Signal and a listener function.
+* Based on JS Signals by Miller Medeiros. Converted by TypeScript by Richard Davey.
+* Released under the MIT license
+* http://millermedeiros.github.com/js-signals/
*/
module Phaser {
diff --git a/Phaser/Sound.ts b/Phaser/SoundManager.ts
similarity index 54%
rename from Phaser/Sound.ts
rename to Phaser/SoundManager.ts
index fe62278c..27c50f00 100644
--- a/Phaser/Sound.ts
+++ b/Phaser/SoundManager.ts
@@ -1,7 +1,9 @@
///
/**
-* Phaser
+* Phaser - SoundManager
+*
+* This is an embroyonic web audio sound management class. There is a lot of work still to do here.
*/
module Phaser {
@@ -119,115 +121,3 @@ module Phaser {
}
}
-
-module Phaser {
-
- export class Sound {
-
- constructor(context, gainNode, data, volume?: number = 1, loop?: bool = false) {
-
- this._context = context;
- this._gainNode = gainNode;
- this._buffer = data;
- this._volume = volume;
- this.loop = loop;
-
- // Local volume control
- if (this._context !== null)
- {
- this._localGainNode = this._context.createGainNode();
- this._localGainNode.connect(this._gainNode);
- this._localGainNode.gain.value = this._volume;
- }
-
- if (this._buffer === null)
- {
- this.isDecoding = true;
- }
- else
- {
- this.play();
- }
-
- }
-
- private _context;
- private _gainNode;
- private _localGainNode;
- private _buffer;
- private _volume: number;
- private _sound;
-
- loop: bool = false;
- duration: number;
- isPlaying: bool = false;
- isDecoding: bool = false;
-
- public setDecodedBuffer(data) {
-
- this._buffer = data;
- this.isDecoding = false;
- this.play();
-
- }
-
- public play() {
-
- if (this._buffer === null || this.isDecoding === true)
- {
- return;
- }
-
- this._sound = this._context.createBufferSource();
- this._sound.buffer = this._buffer;
- this._sound.connect(this._localGainNode);
-
- if (this.loop)
- {
- this._sound.loop = true;
- }
-
- this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it
-
- this.duration = this._sound.buffer.duration;
- this.isPlaying = true;
-
- }
-
- public stop() {
-
- if (this.isPlaying === true)
- {
- this.isPlaying = false;
-
- this._sound.noteOff(0);
- }
-
- }
-
- public mute() {
-
- this._localGainNode.gain.value = 0;
-
- }
-
- public unmute() {
-
- this._localGainNode.gain.value = this._volume;
-
- }
-
- public set volume(value: number) {
-
- this._volume = value;
- this._localGainNode.gain.value = this._volume;
-
- }
-
- public get volume(): number {
- return this._volume;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/Phaser/Stage.ts b/Phaser/Stage.ts
index 46952bc0..485d8ca4 100644
--- a/Phaser/Stage.ts
+++ b/Phaser/Stage.ts
@@ -3,7 +3,10 @@
///
/**
-* Phaser
+* Phaser - Stage
+*
+* The Stage is the canvas on which everything is displayed. This class handles display within the web browser, focus handling,
+* resizing, scaling and pause/boot screens.
*/
module Phaser {
diff --git a/Phaser/State.ts b/Phaser/State.ts
index de454c56..7a9d2069 100644
--- a/Phaser/State.ts
+++ b/Phaser/State.ts
@@ -1,7 +1,9 @@
///
/**
-* Phaser
+* Phaser - State
+*
+* This is a base State class which can be extended if you are creating your game using TypeScript.
*/
module Phaser {
diff --git a/Phaser/Time.ts b/Phaser/Time.ts
index de6d91bf..57bf80a1 100644
--- a/Phaser/Time.ts
+++ b/Phaser/Time.ts
@@ -1,7 +1,9 @@
///
/**
-* Phaser
+* Phaser - Time
+*
+* This is the game clock and it manages elapsed time and calculation of delta values, used for game object motion.
*/
module Phaser {
diff --git a/Phaser/TweenManager.ts b/Phaser/TweenManager.ts
index 45f3519b..5243c22f 100644
--- a/Phaser/TweenManager.ts
+++ b/Phaser/TweenManager.ts
@@ -2,27 +2,14 @@
///
/**
- * Phaser - Tween Manager
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js) converted to TypeScript, patched and integrated into Phaser
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration
- * @author sole / http://soledadpenades.com
- * @author mrdoob / http://mrdoob.com
- * @author Robert Eisele / http://www.xarg.org
- * @author Philippe / http://philippe.elsass.me
- * @author Robert Penner / http://www.robertpenner.com/easing_terms_of_use.html
- * @author Paul Lewis / http://www.aerotwist.com/
- * @author lechecacharro
- * @author Josh Faul / http://jocafa.com/
- * @author egraether / http://egraether.com/
- *
- * @todo
- * 1) Allow for tweening direct numeric values, not just object properties
- * 2) YoYo support
- */
+* Phaser - TweenManager
+*
+* The Game has a single instance of the TweenManager through which all Tween objects are created and updated.
+* Tweens are hooked into the game clock and pause system, adjusting based on the game state.
+* TweenManager is based heavily on tween.js by sole (http://soledadpenades.com).
+* I converted it to TypeScript, swapped the callbacks for signals and patched a few issues with regard
+* to properties and completion errors. Please see https://github.com/sole/tween.js for a full list of contributors.
+*/
module Phaser {
diff --git a/Phaser/World.ts b/Phaser/World.ts
index cbf66ebf..9a200220 100644
--- a/Phaser/World.ts
+++ b/Phaser/World.ts
@@ -1,7 +1,11 @@
///
/**
-* Phaser
+* Phaser - World
+*
+* A game has only one world. The world is an abstract place in which all game objects live. It is not bound
+* by stage limits and can be any size or dimension. You look into the world via cameras and all game objects
+* live within the world at world-based coordinates. By default a world is created the same size as your Stage.
*/
module Phaser {
diff --git a/Phaser/gameobjects/Emitter.ts b/Phaser/gameobjects/Emitter.ts
index fd9bc3dc..00122c3d 100644
--- a/Phaser/gameobjects/Emitter.ts
+++ b/Phaser/gameobjects/Emitter.ts
@@ -2,21 +2,11 @@
///
/**
- * Emitter is a lightweight particle emitter.
- * It can be used for one-time explosions or for
- * continuous fx like rain and fire. Emitter
- * is not optimized or anything; all it does is launch
- * Particle objects out at set intervals
- * by setting their positions and velocities accordingly.
- * It is easy to use and relatively efficient,
- * relying on Group's RECYCLE POWERS.
- *
- * @author Adam Atomic
- * @author Richard Davey
- */
-
-/**
-* Phaser
+* Phaser - Emitter
+*
+* Emitter is a lightweight particle emitter. It can be used for one-time explosions or for
+* continuous effects like rain and fire. All it really does is launch Particle objects out
+* at set intervals, and fixes their positions and velocities accorindgly.
*/
module Phaser {
diff --git a/Phaser/gameobjects/GameObject.ts b/Phaser/gameobjects/GameObject.ts
index abe94f80..55b81ff3 100644
--- a/Phaser/gameobjects/GameObject.ts
+++ b/Phaser/gameobjects/GameObject.ts
@@ -3,7 +3,10 @@
///
/**
-* Phaser
+* Phaser - GameObject
+*
+* This is the base GameObject on which all other game objects are derived. It contains all the logic required for position,
+* motion, size, collision and input.
*/
module Phaser {
diff --git a/Phaser/gameobjects/GeomSprite.ts b/Phaser/gameobjects/GeomSprite.ts
index 3842b969..0bc79d80 100644
--- a/Phaser/gameobjects/GeomSprite.ts
+++ b/Phaser/gameobjects/GeomSprite.ts
@@ -1,7 +1,11 @@
///
/**
-* Phaser
+* Phaser - GeomSprite
+*
+* A GeomSprite is a special kind of GameObject that contains a base geometry class (Circle, Line, Point, Rectangle).
+* They can be rendered in the game and used for collision just like any other game object. Display of them is controlled
+* via the lineWidth / lineColor / fillColor and renderOutline / renderFill properties.
*/
module Phaser {
diff --git a/Phaser/gameobjects/Particle.ts b/Phaser/gameobjects/Particle.ts
index 0ecb0e25..a0e0e2d8 100644
--- a/Phaser/gameobjects/Particle.ts
+++ b/Phaser/gameobjects/Particle.ts
@@ -2,19 +2,10 @@
///
/**
- * This is a simple particle class that extends the default behavior
- * of Sprite to have slightly more specialized behavior
- * common to many game scenarios. You can override and extend this class
- * just like you would Sprite. While Emitter
- * used to work with just any old sprite, it now requires a
- * Particle based class.
- *
- * @author Adam Atomic
- * @author Richard Davey
- */
-
-/**
-* Phaser
+* Phaser - Particle
+*
+* This is a simple particle class that extends a Sprite to have a slightly more
+* specialised behaviour. It is used exclusively by the Emitter class and can be extended as required.
*/
module Phaser {
diff --git a/Phaser/gameobjects/Sprite.ts b/Phaser/gameobjects/Sprite.ts
index 309b9998..383832f0 100644
--- a/Phaser/gameobjects/Sprite.ts
+++ b/Phaser/gameobjects/Sprite.ts
@@ -3,7 +3,10 @@
///
/**
-* Phaser
+* Phaser - Sprite
+*
+* The Sprite GameObject is an extension of the core GameObject that includes support for animation and dynamic textures.
+* It's probably the most used GameObject of all.
*/
module Phaser {
diff --git a/Phaser/gameobjects/Tilemap.ts b/Phaser/gameobjects/Tilemap.ts
index 9d6e72ce..271f430c 100644
--- a/Phaser/gameobjects/Tilemap.ts
+++ b/Phaser/gameobjects/Tilemap.ts
@@ -4,7 +4,10 @@
///
/**
-* Phaser
+* Phaser - Tilemap
+*
+* This GameObject allows for the display of a tilemap within the game world. Tile maps consist of an image, tile data and a size.
+* Internally it creates a TilemapBuffer for each camera in the world.
*/
module Phaser {
diff --git a/Phaser/geom/Circle.ts b/Phaser/geom/Circle.ts
index d847acf8..37e0d885 100644
--- a/Phaser/geom/Circle.ts
+++ b/Phaser/geom/Circle.ts
@@ -1,13 +1,10 @@
///
/**
- * Phaser - Geom - Circle
- *
- * @desc A Circle object is an area defined by its position, as indicated by its center point (x,y) and diameter.
- *
- * @version 1.1 - 11th October 2012
- * @author Richard Davey
- */
+* Phaser - Circle
+*
+* A Circle object is an area defined by its position, as indicated by its center point (x,y) and diameter.
+*/
module Phaser {
diff --git a/Phaser/geom/IntersectResult.ts b/Phaser/geom/IntersectResult.ts
index ee02c1d8..8ceb6fce 100644
--- a/Phaser/geom/IntersectResult.ts
+++ b/Phaser/geom/IntersectResult.ts
@@ -1,13 +1,10 @@
///
/**
- * Phaser - Geom - IntersectResult
- *
- * @desc A light-weight result object to hold the results of an intersection
- *
- * @version 1.0 - 15th October 2012
- * @author Richard Davey
- */
+* Phaser - IntersectResult
+*
+* A light-weight result object to hold the results of an intersection. For when you need more than just true/false.
+*/
module Phaser {
diff --git a/Phaser/geom/Line.ts b/Phaser/geom/Line.ts
index 19ced5fa..64c5f08b 100644
--- a/Phaser/geom/Line.ts
+++ b/Phaser/geom/Line.ts
@@ -1,14 +1,10 @@
///
/**
- * Phaser - Geom - Line
- *
- * @desc A Line object is an infinte line through space. The two sets of x/y coordinates define the Line Segment.
- *
- * @version 1.0 - 11th October 2012
- * @author Ross Kettle
- * @author Richard Davey
- */
+* Phaser - Line
+*
+* A Line object is an infinte line through space. The two sets of x/y coordinates define the Line Segment.
+*/
module Phaser {
diff --git a/Phaser/geom/Point.ts b/Phaser/geom/Point.ts
index dc525614..fbf6aa7a 100644
--- a/Phaser/geom/Point.ts
+++ b/Phaser/geom/Point.ts
@@ -1,17 +1,9 @@
///
/**
- * Point
- *
- * @desc The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.
- *
- * @version 1.2 - 27th February 2013
- * @author Richard Davey
- * @todo polar, interpolate
- */
-
-/**
-* Phaser
+* Phaser - Point
+*
+* The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.
*/
module Phaser {
diff --git a/Phaser/geom/Rectangle.ts b/Phaser/geom/Rectangle.ts
index 561693be..cd6e779b 100644
--- a/Phaser/geom/Rectangle.ts
+++ b/Phaser/geom/Rectangle.ts
@@ -1,16 +1,9 @@
///
/**
- * Rectangle
- *
- * @desc A Rectangle object is an area defined by its position, as indicated by its top-left corner (x,y) and width and height.
- *
- * @version 1.2 - 15th October 2012
- * @author Richard Davey
- */
-
-/**
-* Phaser
+* Phaser - Rectangle
+*
+* A Rectangle object is an area defined by its position, as indicated by its top-left corner (x,y) and width and height.
*/
module Phaser {
diff --git a/Phaser/system/Camera.ts b/Phaser/system/Camera.ts
index 4908d746..6f1ca250 100644
--- a/Phaser/system/Camera.ts
+++ b/Phaser/system/Camera.ts
@@ -2,7 +2,11 @@
///
/**
-* Phaser
+* Phaser - Camera
+*
+* A Camera is your view into the game world. It has a position, size, scale and rotation and renders only those objects
+* within its field of view. The game automatically creates a single Stage sized camera on boot, but it can be changed and
+* additional cameras created via the CameraManager.
*/
module Phaser {
diff --git a/Phaser/system/Device.ts b/Phaser/system/Device.ts
index b09a8bde..cd1c7161 100644
--- a/Phaser/system/Device.ts
+++ b/Phaser/system/Device.ts
@@ -1,19 +1,10 @@
///
/**
- * Device
- *
- * @desc Detects device support capabilities. Using some elements from System.js by MrDoob and Modernizr
- * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/audio.js
- *
- * @version 1.0 - March 5th 2013
- * @author Richard Davey
- * @author mrdoob
- * @author Modernizr team
- */
-
-/**
-* Phaser
+* Phaser - Device
+*
+* Detects device support capabilities. Using some elements from System.js by MrDoob and Modernizr
+* https://github.com/Modernizr/Modernizr/blob/master/feature-detects/audio.js
*/
module Phaser {
diff --git a/Phaser/system/LinkedList.ts b/Phaser/system/LinkedList.ts
index 41d6b6a2..61ac12d4 100644
--- a/Phaser/system/LinkedList.ts
+++ b/Phaser/system/LinkedList.ts
@@ -1,13 +1,9 @@
///
/**
- * A miniature linked list class.
- * Useful for optimizing time-critical or highly repetitive tasks!
- * See QuadTree for how to use it, IF YOU DARE.
- */
-
-/**
-* Phaser
+* Phaser - LinkedList
+*
+* A miniature linked list class. Useful for optimizing time-critical or highly repetitive tasks!
*/
module Phaser {
diff --git a/Phaser/system/QuadTree.ts b/Phaser/system/QuadTree.ts
index b2ed792b..e157fb8c 100644
--- a/Phaser/system/QuadTree.ts
+++ b/Phaser/system/QuadTree.ts
@@ -2,15 +2,11 @@
///
/**
- * A fairly generic quad tree structure for rapid overlap checks.
- * QuadTree is also configured for single or dual list operation.
- * You can add items either to its A list or its B list.
- * When you do an overlap check, you can compare the A list to itself,
- * or the A list against the B list. Handy for different things!
- */
-
-/**
-* Phaser
+* Phaser - QuadTree
+*
+* A fairly generic quad tree structure for rapid overlap checks. QuadTree is also configured for single or dual list operation.
+* You can add items either to its A list or its B list. When you do an overlap check, you can compare the A list to itself,
+* or the A list against the B list. Handy for different things!
*/
module Phaser {
diff --git a/Phaser/system/RandomDataGenerator.ts b/Phaser/system/RandomDataGenerator.ts
index fff84e3c..2bc3415f 100644
--- a/Phaser/system/RandomDataGenerator.ts
+++ b/Phaser/system/RandomDataGenerator.ts
@@ -1,19 +1,11 @@
///
/**
- * Repeatable Random Data Generator
- *
- * @desc Manages the creation of unique internal game IDs
- * Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense
- * Random number generator from http://baagoe.org/en/wiki/Better_random_numbers_for_javascript
- *
- * @version 1.1 - 1st March 2013
- * @author Josh Faul
- * @author Richard Davey, TypeScript conversion and additional methods
- */
-
-/**
-* Phaser
+* Phaser - RandomDataGenerator
+*
+* An extremely useful repeatable random data generator. Access it via Game.rnd
+* Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense
+* Random number generator from http://baagoe.org/en/wiki/Better_random_numbers_for_javascript
*/
module Phaser {
diff --git a/Phaser/system/RequestAnimationFrame.ts b/Phaser/system/RequestAnimationFrame.ts
index ba3f78a2..c8a804c6 100644
--- a/Phaser/system/RequestAnimationFrame.ts
+++ b/Phaser/system/RequestAnimationFrame.ts
@@ -1,16 +1,9 @@
///
/**
- * RequestAnimationFrame
- *
- * @desc Abstracts away the use of RAF or setTimeOut for the core game update loop. The callback can be re-mapped on the fly.
- *
- * @version 0.3 - 15th October 2012
- * @author Richard Davey
- */
-
-/**
-* Phaser
+* Phaser - RequestAnimationFrame
+*
+* Abstracts away the use of RAF or setTimeOut for the core game update loop. The callback can be re-mapped on the fly.
*/
module Phaser {
diff --git a/Phaser/system/Sound.ts b/Phaser/system/Sound.ts
new file mode 100644
index 00000000..1ee00b77
--- /dev/null
+++ b/Phaser/system/Sound.ts
@@ -0,0 +1,120 @@
+///
+///
+
+/**
+* Phaser - Sound
+*
+* A Sound file, used by the Game.SoundManager for playback.
+*/
+
+module Phaser {
+
+ export class Sound {
+
+ constructor(context, gainNode, data, volume?: number = 1, loop?: bool = false) {
+
+ this._context = context;
+ this._gainNode = gainNode;
+ this._buffer = data;
+ this._volume = volume;
+ this.loop = loop;
+
+ // Local volume control
+ if (this._context !== null)
+ {
+ this._localGainNode = this._context.createGainNode();
+ this._localGainNode.connect(this._gainNode);
+ this._localGainNode.gain.value = this._volume;
+ }
+
+ if (this._buffer === null)
+ {
+ this.isDecoding = true;
+ }
+ else
+ {
+ this.play();
+ }
+
+ }
+
+ private _context;
+ private _gainNode;
+ private _localGainNode;
+ private _buffer;
+ private _volume: number;
+ private _sound;
+
+ loop: bool = false;
+ duration: number;
+ isPlaying: bool = false;
+ isDecoding: bool = false;
+
+ public setDecodedBuffer(data) {
+
+ this._buffer = data;
+ this.isDecoding = false;
+ this.play();
+
+ }
+
+ public play() {
+
+ if (this._buffer === null || this.isDecoding === true)
+ {
+ return;
+ }
+
+ this._sound = this._context.createBufferSource();
+ this._sound.buffer = this._buffer;
+ this._sound.connect(this._localGainNode);
+
+ if (this.loop)
+ {
+ this._sound.loop = true;
+ }
+
+ this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it
+
+ this.duration = this._sound.buffer.duration;
+ this.isPlaying = true;
+
+ }
+
+ public stop() {
+
+ if (this.isPlaying === true)
+ {
+ this.isPlaying = false;
+
+ this._sound.noteOff(0);
+ }
+
+ }
+
+ public mute() {
+
+ this._localGainNode.gain.value = 0;
+
+ }
+
+ public unmute() {
+
+ this._localGainNode.gain.value = this._volume;
+
+ }
+
+ public set volume(value: number) {
+
+ this._volume = value;
+ this._localGainNode.gain.value = this._volume;
+
+ }
+
+ public get volume(): number {
+ return this._volume;
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/Phaser/system/StageScaleMode.ts b/Phaser/system/StageScaleMode.ts
index 4c3ae3ac..fdca2075 100644
--- a/Phaser/system/StageScaleMode.ts
+++ b/Phaser/system/StageScaleMode.ts
@@ -1,16 +1,11 @@
///
-/*
- * Based on code from Viewporter v2.0
- * http://github.com/zynga/viewporter
- *
- * Copyright 2011, Zynga Inc.
- * Licensed under the MIT License.
- * https://raw.github.com/zynga/viewporter/master/MIT-LICENSE.txt
- */
-
/**
-* Phaser
+* Phaser - StageScaleMode
+*
+* This class controls the scaling of your game. On mobile devices it will also remove the URL bar and allow
+* you to maintain proportion and aspect ratio.
+* It is based on a technique taken from Viewporter v2.0 by Zynga Inc. http://github.com/zynga/viewporter
*/
module Phaser {
diff --git a/Phaser/system/Tile.ts b/Phaser/system/Tile.ts
index d509f4b6..5505a6db 100644
--- a/Phaser/system/Tile.ts
+++ b/Phaser/system/Tile.ts
@@ -1,16 +1,9 @@
///
/**
- * A simple helper object for Tilemap that helps expand collision opportunities and control.
- * You can use Tilemap.setTileProperties() to alter the collision properties and
- * callback functions and filters for this object to do things like one-way tiles or whatever.
- *
- * @author Adam Atomic
- * @author Richard Davey
- */
-
-/**
-* Phaser
+* Phaser - Tile
+*
+* A simple helper object for Tilemap that helps expand collision opportunities and control.
*/
module Phaser {
diff --git a/Phaser/system/TilemapBuffer.ts b/Phaser/system/TilemapBuffer.ts
index f00387f2..cd588dd5 100644
--- a/Phaser/system/TilemapBuffer.ts
+++ b/Phaser/system/TilemapBuffer.ts
@@ -1,9 +1,9 @@
///
/**
-* A Tilemap Buffer
-*
-* @author Richard Davey
+* Phaser - TilemapBuffer
+*
+* Responsible for rendering a portion of a tilemap to the given Camera.
*/
module Phaser {
diff --git a/Phaser/system/Tween.ts b/Phaser/system/Tween.ts
index ff6638ae..6c64b4ed 100644
--- a/Phaser/system/Tween.ts
+++ b/Phaser/system/Tween.ts
@@ -12,14 +12,10 @@
///
/**
- * Phaser - Tween
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js) converted to TypeScript and integrated into Phaser
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
+* Phaser - Tween
+*
+* Based heavily on tween.js by sole (https://github.com/sole/tween.js) converted to TypeScript and integrated into Phaser
+*/
module Phaser {
diff --git a/Phaser/system/animation/Animation.ts b/Phaser/system/animation/Animation.ts
index 3ed5df22..ca31284f 100644
--- a/Phaser/system/animation/Animation.ts
+++ b/Phaser/system/animation/Animation.ts
@@ -1,16 +1,9 @@
///
/**
- * Animation
- *
- * @desc Loads Sprite Sheets and Texture Atlas formats into a unified FrameData object
- *
- * @version 1.0 - 22nd March 2013
- * @author Richard Davey
- */
-
-/**
-* Phaser
+* Phaser - Animation
+*
+* An Animation is a single animation. It is created by the AnimationManager and belongs to Sprite objects.
*/
module Phaser {
diff --git a/Phaser/system/animation/AnimationLoader.ts b/Phaser/system/animation/AnimationLoader.ts
index a496756c..dd5e3da0 100644
--- a/Phaser/system/animation/AnimationLoader.ts
+++ b/Phaser/system/animation/AnimationLoader.ts
@@ -1,7 +1,9 @@
///
/**
-* Phaser
+* Phaser - AnimationLoader
+*
+* Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations.
*/
module Phaser {
diff --git a/Phaser/system/animation/Frame.ts b/Phaser/system/animation/Frame.ts
index 4f6abe11..5aa4d263 100644
--- a/Phaser/system/animation/Frame.ts
+++ b/Phaser/system/animation/Frame.ts
@@ -1,7 +1,9 @@
///
/**
-* Phaser
+* Phaser - Frame
+*
+* A Frame is a single frame of an animation and is part of a FrameData collection.
*/
module Phaser {
diff --git a/Phaser/system/animation/FrameData.ts b/Phaser/system/animation/FrameData.ts
index c0712ad9..04441914 100644
--- a/Phaser/system/animation/FrameData.ts
+++ b/Phaser/system/animation/FrameData.ts
@@ -1,7 +1,9 @@
///
/**
-* Phaser
+* Phaser - FrameData
+*
+* FrameData is a container for Frame objects, the internal representation of animation data in Phaser.
*/
module Phaser {
diff --git a/Phaser/system/easing/Back.ts b/Phaser/system/easing/Back.ts
index 1add77c9..b4f731e5 100644
--- a/Phaser/system/easing/Back.ts
+++ b/Phaser/system/easing/Back.ts
@@ -1,14 +1,10 @@
///
/**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
+* Phaser - Easing - Back
+*
+* For use with Phaser.Tween
+*/
module Phaser.Easing {
diff --git a/Phaser/system/easing/Bounce.ts b/Phaser/system/easing/Bounce.ts
index 714b2228..7eb5e713 100644
--- a/Phaser/system/easing/Bounce.ts
+++ b/Phaser/system/easing/Bounce.ts
@@ -1,14 +1,10 @@
///
/**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
+* Phaser - Easing - Bounce
+*
+* For use with Phaser.Tween
+*/
module Phaser.Easing {
diff --git a/Phaser/system/easing/Circular.ts b/Phaser/system/easing/Circular.ts
index fb534e6e..b2d86ac9 100644
--- a/Phaser/system/easing/Circular.ts
+++ b/Phaser/system/easing/Circular.ts
@@ -1,14 +1,10 @@
///
/**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
+* Phaser - Easing - Circular
+*
+* For use with Phaser.Tween
+*/
module Phaser.Easing {
diff --git a/Phaser/system/easing/Cubic.ts b/Phaser/system/easing/Cubic.ts
index f90d6cbf..6e6fe843 100644
--- a/Phaser/system/easing/Cubic.ts
+++ b/Phaser/system/easing/Cubic.ts
@@ -1,14 +1,10 @@
///
/**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
+* Phaser - Easing - Cubic
+*
+* For use with Phaser.Tween
+*/
module Phaser.Easing {
diff --git a/Phaser/system/easing/Elastic.ts b/Phaser/system/easing/Elastic.ts
index 8fc9307e..165c739a 100644
--- a/Phaser/system/easing/Elastic.ts
+++ b/Phaser/system/easing/Elastic.ts
@@ -1,14 +1,10 @@
///
/**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
+* Phaser - Easing - Elastic
+*
+* For use with Phaser.Tween
+*/
module Phaser.Easing {
diff --git a/Phaser/system/easing/Exponential.ts b/Phaser/system/easing/Exponential.ts
index 0e0f503e..e05adabd 100644
--- a/Phaser/system/easing/Exponential.ts
+++ b/Phaser/system/easing/Exponential.ts
@@ -1,14 +1,10 @@
///
/**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
+* Phaser - Easing - Exponential
+*
+* For use with Phaser.Tween
+*/
module Phaser.Easing {
diff --git a/Phaser/system/easing/Linear.ts b/Phaser/system/easing/Linear.ts
index ff585549..70e9d9f2 100644
--- a/Phaser/system/easing/Linear.ts
+++ b/Phaser/system/easing/Linear.ts
@@ -1,14 +1,10 @@
///
/**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
+* Phaser - Easing - Linear
+*
+* For use with Phaser.Tween
+*/
module Phaser.Easing {
diff --git a/Phaser/system/easing/Quadratic.ts b/Phaser/system/easing/Quadratic.ts
index 0ea101ec..bde2f88b 100644
--- a/Phaser/system/easing/Quadratic.ts
+++ b/Phaser/system/easing/Quadratic.ts
@@ -1,14 +1,10 @@
///
/**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
+* Phaser - Easing - Quadratic
+*
+* For use with Phaser.Tween
+*/
module Phaser.Easing {
diff --git a/Phaser/system/easing/Quartic.ts b/Phaser/system/easing/Quartic.ts
index a43c25e2..7f89278b 100644
--- a/Phaser/system/easing/Quartic.ts
+++ b/Phaser/system/easing/Quartic.ts
@@ -1,14 +1,10 @@
///
/**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
+* Phaser - Easing - Quartic
+*
+* For use with Phaser.Tween
+*/
module Phaser.Easing {
diff --git a/Phaser/system/easing/Quintic.ts b/Phaser/system/easing/Quintic.ts
index 78ed48e0..8fe2f7ef 100644
--- a/Phaser/system/easing/Quintic.ts
+++ b/Phaser/system/easing/Quintic.ts
@@ -1,14 +1,10 @@
///
/**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
+* Phaser - Easing - Quintic
+*
+* For use with Phaser.Tween
+*/
module Phaser.Easing {
diff --git a/Phaser/system/easing/Sinusoidal.ts b/Phaser/system/easing/Sinusoidal.ts
index 1406b015..053404b8 100644
--- a/Phaser/system/easing/Sinusoidal.ts
+++ b/Phaser/system/easing/Sinusoidal.ts
@@ -1,14 +1,10 @@
///
/**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
+* Phaser - Easing - Sinusoidal
+*
+* For use with Phaser.Tween
+*/
module Phaser.Easing {
diff --git a/Phaser/system/input/Finger.ts b/Phaser/system/input/Finger.ts
index a052ae8e..fbf9555b 100644
--- a/Phaser/system/input/Finger.ts
+++ b/Phaser/system/input/Finger.ts
@@ -1,18 +1,9 @@
///
/**
- * Input - Finger
- *
- * @desc A Finger object used by the Touch manager
- *
- * @version 1.1 - 27th February 2013
- * @author Richard Davey
- *
- * @todo Lots
- */
-
-/**
-* Phaser
+* Phaser - Finger
+*
+* A Finger object is used by the Touch manager and represents a single finger on the touch screen.
*/
module Phaser {
diff --git a/Phaser/system/input/Input.ts b/Phaser/system/input/Input.ts
index 979e8128..9288df1b 100644
--- a/Phaser/system/input/Input.ts
+++ b/Phaser/system/input/Input.ts
@@ -2,7 +2,9 @@
///
/**
-* Phaser
+* Phaser - Input
+*
+* A game specific Input manager that looks after the mouse, keyboard and touch objects. This is updated by the core game loop.
*/
module Phaser {
diff --git a/Phaser/system/input/Keyboard.ts b/Phaser/system/input/Keyboard.ts
index f5c6530c..c8e25a18 100644
--- a/Phaser/system/input/Keyboard.ts
+++ b/Phaser/system/input/Keyboard.ts
@@ -1,7 +1,11 @@
///
/**
-* Phaser
+* Phaser - Keyboard
+*
+* The Keyboard class handles keyboard interactions with the game and the resulting events.
+* The avoid stealing all browser input we don't use event.preventDefault. If you would like to trap a specific key however
+* then use the addKeyCapture() method.
*/
module Phaser {
diff --git a/Phaser/system/input/Mouse.ts b/Phaser/system/input/Mouse.ts
index 885ef500..4918676f 100644
--- a/Phaser/system/input/Mouse.ts
+++ b/Phaser/system/input/Mouse.ts
@@ -1,7 +1,9 @@
///
/**
-* Phaser
+* Phaser - Mouse
+*
+* The Mouse class handles mouse interactions with the game and the resulting events.
*/
module Phaser {
diff --git a/Phaser/system/input/Touch.ts b/Phaser/system/input/Touch.ts
index 71ef8a72..ccad9bb9 100644
--- a/Phaser/system/input/Touch.ts
+++ b/Phaser/system/input/Touch.ts
@@ -2,25 +2,19 @@
///
/**
- * Input - Touch
- *
- * @desc http://www.w3.org/TR/touch-events/
- * https://developer.mozilla.org/en-US/docs/DOM/TouchList
- * http://www.html5rocks.com/en/mobile/touchandmouse/
- * Android 2.x only supports 1 touch event at once, no multi-touch
- *
- * @version 1.1 - 27th February 2013
- * @author Richard Davey
- *
- * @todo Try and resolve update lag in Chrome/Android
- * Gestures (pinch, zoom, swipe)
- * GameObject Touch
- * Touch point within GameObject
- * Input Zones (mouse and touch) - lock entities within them + axis aligned drags
- */
-
-/**
-* Phaser
+* Phaser - Touch
+*
+* The Touch class handles touch interactions with the game and the resulting Finger objects.
+* http://www.w3.org/TR/touch-events/
+* https://developer.mozilla.org/en-US/docs/DOM/TouchList
+* http://www.html5rocks.com/en/mobile/touchandmouse/
+* Note: Android 2.x only supports 1 touch event at once, no multi-touch
+*
+* @todo Try and resolve update lag in Chrome/Android
+* Gestures (pinch, zoom, swipe)
+* GameObject Touch
+* Touch point within GameObject
+* Input Zones (mouse and touch) - lock entities within them + axis aligned drags
*/
module Phaser {
diff --git a/build/phaser.js b/build/phaser.js
index c6d155bc..e3b6900a 100644
--- a/build/phaser.js
+++ b/build/phaser.js
@@ -1,14 +1,9 @@
///
/**
-* This is a useful "generic" object.
-* Both GameObject and Group extend this class,
-* as do the plugins. Has no size, position or graphical data.
+* Phaser - Basic
*
-* @author Adam Atomic
-* @author Richard Davey
-*/
-/**
-* Phaser
+* A useful "generic" object on which all GameObjects and Groups are based.
+* It has no size, position or graphical data.
*/
var Phaser;
(function (Phaser) {
@@ -1361,6 +1356,12 @@ var Phaser;
///
///
///
+/**
+* Phaser - AnimationManager
+*
+* Any Sprite that has animation contains an instance of the AnimationManager, which is used to add, play and update
+* sprite specific animations.
+*/
var Phaser;
(function (Phaser) {
var AnimationManager = (function () {
@@ -1481,7 +1482,10 @@ var Phaser;
})(Phaser || (Phaser = {}));
///
/**
-* Phaser
+* Phaser - Cache
+*
+* A game only has one instance of a Cache and it is used to store all externally loaded assets such
+* as images, sounds and data files as a result of Loader calls. Cache items use string based keys for look-up.
*/
var Phaser;
(function (Phaser) {
@@ -2124,10 +2128,14 @@ var Phaser;
})(Phaser || (Phaser = {}));
///
///
-// TODO: If the Camera is larger than the Stage size then the rotation offset isn't correct
-// TODO: Texture Repeat doesn't scroll, because it's part of the camera not the world, need to think about this more
/**
-* Phaser
+* Phaser - CameraManager
+*
+* Your game only has one CameraManager instance and it's responsible for looking after, creating and destroying
+* all of the cameras in the world.
+*
+* TODO: If the Camera is larger than the Stage size then the rotation offset isn't correct
+* TODO: Texture Repeat doesn't scroll, because it's part of the camera not the world, need to think about this more
*/
var Phaser;
(function (Phaser) {
@@ -4108,7 +4116,9 @@ var Phaser;
///
///
/**
-* Phaser - Collision
+* Phaser - Collision
+*
+* A set of extremely useful collision and geometry intersection functions.
*/
var Phaser;
(function (Phaser) {
@@ -4772,7 +4782,12 @@ var Phaser;
})(Phaser || (Phaser = {}));
///
/**
-* Phaser
+* Phaser - DynamicTexture
+*
+* A DynamicTexture can be thought of as a mini canvas into which you can draw anything.
+* Game Objects can be assigned a DynamicTexture, so when they render in the world they do so
+* based on the contents of the texture at the time. This allows you to create powerful effects
+* once and have them replicated across as many game objects as you like.
*/
var Phaser;
(function (Phaser) {
@@ -4926,13 +4941,10 @@ var Phaser;
})(Phaser || (Phaser = {}));
///
/**
-* Phaser - GameMath
+* Phaser - GameMath
*
-* @desc Adds a set of extra Math functions and extends a few commonly used ones.
-* Includes methods written by Dylan Engelman and Adam Saltsman.
-*
-* @version 1.0 - 17th March 2013
-* @author Richard Davey
+* Adds a set of extra Math functions used through-out Phaser.
+* Includes methods written by Dylan Engelman and Adam Saltsman.
*/
var Phaser;
(function (Phaser) {
@@ -5780,15 +5792,10 @@ var Phaser;
///
///
/**
-* This is an organizational class that can update and render a bunch of Basics.
-* NOTE: Although Group extends Basic, it will not automatically
-* add itself to the global collisions quad tree, it will only add its members.
+* Phaser - Group
+*
+* This class is used for organising, updating and sorting game objects.
*
-* @author Adam Atomic
-* @author Richard Davey
-*/
-/**
-* Phaser
*/
var Phaser;
(function (Phaser) {
@@ -6897,7 +6904,9 @@ var Phaser;
})(Phaser || (Phaser = {}));
///
/**
-* Phaser
+* Phaser - SoundManager
+*
+* This is an embroyonic web audio sound management class. There is a lot of work still to do here.
*/
var Phaser;
(function (Phaser) {
@@ -6978,79 +6987,6 @@ var Phaser;
})();
Phaser.SoundManager = SoundManager;
})(Phaser || (Phaser = {}));
-var Phaser;
-(function (Phaser) {
- var Sound = (function () {
- function Sound(context, gainNode, data, volume, loop) {
- if (typeof volume === "undefined") { volume = 1; }
- if (typeof loop === "undefined") { loop = false; }
- this.loop = false;
- this.isPlaying = false;
- this.isDecoding = false;
- this._context = context;
- this._gainNode = gainNode;
- this._buffer = data;
- this._volume = volume;
- this.loop = loop;
- // Local volume control
- if(this._context !== null) {
- this._localGainNode = this._context.createGainNode();
- this._localGainNode.connect(this._gainNode);
- this._localGainNode.gain.value = this._volume;
- }
- if(this._buffer === null) {
- this.isDecoding = true;
- } else {
- this.play();
- }
- }
- Sound.prototype.setDecodedBuffer = function (data) {
- this._buffer = data;
- this.isDecoding = false;
- this.play();
- };
- Sound.prototype.play = function () {
- if(this._buffer === null || this.isDecoding === true) {
- return;
- }
- this._sound = this._context.createBufferSource();
- this._sound.buffer = this._buffer;
- this._sound.connect(this._localGainNode);
- if(this.loop) {
- this._sound.loop = true;
- }
- this._sound.noteOn(0)// the zero is vitally important, crashes iOS6 without it
- ;
- this.duration = this._sound.buffer.duration;
- this.isPlaying = true;
- };
- Sound.prototype.stop = function () {
- if(this.isPlaying === true) {
- this.isPlaying = false;
- this._sound.noteOff(0);
- }
- };
- Sound.prototype.mute = function () {
- this._localGainNode.gain.value = 0;
- };
- Sound.prototype.unmute = function () {
- this._localGainNode.gain.value = this._volume;
- };
- Object.defineProperty(Sound.prototype, "volume", {
- get: function () {
- return this._volume;
- },
- set: function (value) {
- this._volume = value;
- this._localGainNode.gain.value = this._volume;
- },
- enumerable: true,
- configurable: true
- });
- return Sound;
- })();
- Phaser.Sound = Sound;
-})(Phaser || (Phaser = {}));
/**
* Phaser
*
@@ -7059,7 +6995,8 @@ var Phaser;
* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
*
* Richard Davey (@photonstorm)
-* Adam Saltsman (@ADAMATOMIC) (original Flixel code)
+*
+* Many thanks to Adam Saltsman (@ADAMATOMIC) for the original Flixel AS3 code on which Phaser is based.
*
* "If you want your children to be intelligent, read them fairy tales."
* "If you want them to be more intelligent, read them more fairy tales."
@@ -7185,7 +7122,10 @@ var Phaser;
///
///
/**
-* Phaser
+* Phaser - Stage
+*
+* The Stage is the canvas on which everything is displayed. This class handles display within the web browser, focus handling,
+* resizing, scaling and pause/boot screens.
*/
var Phaser;
(function (Phaser) {
@@ -7374,7 +7314,9 @@ var Phaser;
})(Phaser || (Phaser = {}));
///
/**
-* Phaser
+* Phaser - Time
+*
+* This is the game clock and it manages elapsed time and calculation of delta values, used for game object motion.
*/
var Phaser;
(function (Phaser) {
@@ -7480,29 +7422,598 @@ var Phaser;
})();
Phaser.Time = Time;
})(Phaser || (Phaser = {}));
-///
-///
+var Phaser;
+(function (Phaser) {
+ ///
+ /**
+ * Phaser - Easing
+ *
+ * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
+ *
+ * @version 1.0 - 11th January 2013
+ *
+ * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+ */
+ (function (Easing) {
+ var Back = (function () {
+ function Back() { }
+ Back.In = function In(k) {
+ var s = 1.70158;
+ return k * k * ((s + 1) * k - s);
+ };
+ Back.Out = function Out(k) {
+ var s = 1.70158;
+ return --k * k * ((s + 1) * k + s) + 1;
+ };
+ Back.InOut = function InOut(k) {
+ var s = 1.70158 * 1.525;
+ if((k *= 2) < 1) {
+ return 0.5 * (k * k * ((s + 1) * k - s));
+ }
+ return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
+ };
+ return Back;
+ })();
+ Easing.Back = Back;
+ })(Phaser.Easing || (Phaser.Easing = {}));
+ var Easing = Phaser.Easing;
+})(Phaser || (Phaser = {}));
+var Phaser;
+(function (Phaser) {
+ ///
+ /**
+ * Phaser - Easing
+ *
+ * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
+ *
+ * @version 1.0 - 11th January 2013
+ *
+ * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+ */
+ (function (Easing) {
+ var Bounce = (function () {
+ function Bounce() { }
+ Bounce.In = function In(k) {
+ return 1 - Phaser.Easing.Bounce.Out(1 - k);
+ };
+ Bounce.Out = function Out(k) {
+ if(k < (1 / 2.75)) {
+ return 7.5625 * k * k;
+ } else if(k < (2 / 2.75)) {
+ return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
+ } else if(k < (2.5 / 2.75)) {
+ return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
+ } else {
+ return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
+ }
+ };
+ Bounce.InOut = function InOut(k) {
+ if(k < 0.5) {
+ return Phaser.Easing.Bounce.In(k * 2) * 0.5;
+ }
+ return Phaser.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5;
+ };
+ return Bounce;
+ })();
+ Easing.Bounce = Bounce;
+ })(Phaser.Easing || (Phaser.Easing = {}));
+ var Easing = Phaser.Easing;
+})(Phaser || (Phaser = {}));
+var Phaser;
+(function (Phaser) {
+ ///
+ /**
+ * Phaser - Easing
+ *
+ * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
+ *
+ * @version 1.0 - 11th January 2013
+ *
+ * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+ */
+ (function (Easing) {
+ var Circular = (function () {
+ function Circular() { }
+ Circular.In = function In(k) {
+ return 1 - Math.sqrt(1 - k * k);
+ };
+ Circular.Out = function Out(k) {
+ return Math.sqrt(1 - (--k * k));
+ };
+ Circular.InOut = function InOut(k) {
+ if((k *= 2) < 1) {
+ return -0.5 * (Math.sqrt(1 - k * k) - 1);
+ }
+ return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
+ };
+ return Circular;
+ })();
+ Easing.Circular = Circular;
+ })(Phaser.Easing || (Phaser.Easing = {}));
+ var Easing = Phaser.Easing;
+})(Phaser || (Phaser = {}));
+var Phaser;
+(function (Phaser) {
+ ///
+ /**
+ * Phaser - Easing
+ *
+ * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
+ *
+ * @version 1.0 - 11th January 2013
+ *
+ * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+ */
+ (function (Easing) {
+ var Cubic = (function () {
+ function Cubic() { }
+ Cubic.In = function In(k) {
+ return k * k * k;
+ };
+ Cubic.Out = function Out(k) {
+ return --k * k * k + 1;
+ };
+ Cubic.InOut = function InOut(k) {
+ if((k *= 2) < 1) {
+ return 0.5 * k * k * k;
+ }
+ return 0.5 * ((k -= 2) * k * k + 2);
+ };
+ return Cubic;
+ })();
+ Easing.Cubic = Cubic;
+ })(Phaser.Easing || (Phaser.Easing = {}));
+ var Easing = Phaser.Easing;
+})(Phaser || (Phaser = {}));
+var Phaser;
+(function (Phaser) {
+ ///
+ /**
+ * Phaser - Easing
+ *
+ * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
+ *
+ * @version 1.0 - 11th January 2013
+ *
+ * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+ */
+ (function (Easing) {
+ var Elastic = (function () {
+ function Elastic() { }
+ Elastic.In = function In(k) {
+ var s, a = 0.1, p = 0.4;
+ if(k === 0) {
+ return 0;
+ }
+ if(k === 1) {
+ return 1;
+ }
+ if(!a || a < 1) {
+ a = 1;
+ s = p / 4;
+ } else {
+ s = p * Math.asin(1 / a) / (2 * Math.PI);
+ }
+ return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
+ };
+ Elastic.Out = function Out(k) {
+ var s, a = 0.1, p = 0.4;
+ if(k === 0) {
+ return 0;
+ }
+ if(k === 1) {
+ return 1;
+ }
+ if(!a || a < 1) {
+ a = 1;
+ s = p / 4;
+ } else {
+ s = p * Math.asin(1 / a) / (2 * Math.PI);
+ }
+ return (a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1);
+ };
+ Elastic.InOut = function InOut(k) {
+ var s, a = 0.1, p = 0.4;
+ if(k === 0) {
+ return 0;
+ }
+ if(k === 1) {
+ return 1;
+ }
+ if(!a || a < 1) {
+ a = 1;
+ s = p / 4;
+ } else {
+ s = p * Math.asin(1 / a) / (2 * Math.PI);
+ }
+ if((k *= 2) < 1) {
+ return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
+ }
+ return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
+ };
+ return Elastic;
+ })();
+ Easing.Elastic = Elastic;
+ })(Phaser.Easing || (Phaser.Easing = {}));
+ var Easing = Phaser.Easing;
+})(Phaser || (Phaser = {}));
+var Phaser;
+(function (Phaser) {
+ ///
+ /**
+ * Phaser - Easing
+ *
+ * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
+ *
+ * @version 1.0 - 11th January 2013
+ *
+ * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+ */
+ (function (Easing) {
+ var Exponential = (function () {
+ function Exponential() { }
+ Exponential.In = function In(k) {
+ return k === 0 ? 0 : Math.pow(1024, k - 1);
+ };
+ Exponential.Out = function Out(k) {
+ return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
+ };
+ Exponential.InOut = function InOut(k) {
+ if(k === 0) {
+ return 0;
+ }
+ if(k === 1) {
+ return 1;
+ }
+ if((k *= 2) < 1) {
+ return 0.5 * Math.pow(1024, k - 1);
+ }
+ return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
+ };
+ return Exponential;
+ })();
+ Easing.Exponential = Exponential;
+ })(Phaser.Easing || (Phaser.Easing = {}));
+ var Easing = Phaser.Easing;
+})(Phaser || (Phaser = {}));
+var Phaser;
+(function (Phaser) {
+ ///
+ /**
+ * Phaser - Easing
+ *
+ * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
+ *
+ * @version 1.0 - 11th January 2013
+ *
+ * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+ */
+ (function (Easing) {
+ var Linear = (function () {
+ function Linear() { }
+ Linear.None = function None(k) {
+ return k;
+ };
+ return Linear;
+ })();
+ Easing.Linear = Linear;
+ })(Phaser.Easing || (Phaser.Easing = {}));
+ var Easing = Phaser.Easing;
+})(Phaser || (Phaser = {}));
+var Phaser;
+(function (Phaser) {
+ ///
+ /**
+ * Phaser - Easing
+ *
+ * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
+ *
+ * @version 1.0 - 11th January 2013
+ *
+ * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+ */
+ (function (Easing) {
+ var Quadratic = (function () {
+ function Quadratic() { }
+ Quadratic.In = function In(k) {
+ return k * k;
+ };
+ Quadratic.Out = function Out(k) {
+ return k * (2 - k);
+ };
+ Quadratic.InOut = function InOut(k) {
+ if((k *= 2) < 1) {
+ return 0.5 * k * k;
+ }
+ return -0.5 * (--k * (k - 2) - 1);
+ };
+ return Quadratic;
+ })();
+ Easing.Quadratic = Quadratic;
+ })(Phaser.Easing || (Phaser.Easing = {}));
+ var Easing = Phaser.Easing;
+})(Phaser || (Phaser = {}));
+var Phaser;
+(function (Phaser) {
+ ///
+ /**
+ * Phaser - Easing
+ *
+ * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
+ *
+ * @version 1.0 - 11th January 2013
+ *
+ * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+ */
+ (function (Easing) {
+ var Quartic = (function () {
+ function Quartic() { }
+ Quartic.In = function In(k) {
+ return k * k * k * k;
+ };
+ Quartic.Out = function Out(k) {
+ return 1 - (--k * k * k * k);
+ };
+ Quartic.InOut = function InOut(k) {
+ if((k *= 2) < 1) {
+ return 0.5 * k * k * k * k;
+ }
+ return -0.5 * ((k -= 2) * k * k * k - 2);
+ };
+ return Quartic;
+ })();
+ Easing.Quartic = Quartic;
+ })(Phaser.Easing || (Phaser.Easing = {}));
+ var Easing = Phaser.Easing;
+})(Phaser || (Phaser = {}));
+var Phaser;
+(function (Phaser) {
+ ///
+ /**
+ * Phaser - Easing
+ *
+ * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
+ *
+ * @version 1.0 - 11th January 2013
+ *
+ * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+ */
+ (function (Easing) {
+ var Quintic = (function () {
+ function Quintic() { }
+ Quintic.In = function In(k) {
+ return k * k * k * k * k;
+ };
+ Quintic.Out = function Out(k) {
+ return --k * k * k * k * k + 1;
+ };
+ Quintic.InOut = function InOut(k) {
+ if((k *= 2) < 1) {
+ return 0.5 * k * k * k * k * k;
+ }
+ return 0.5 * ((k -= 2) * k * k * k * k + 2);
+ };
+ return Quintic;
+ })();
+ Easing.Quintic = Quintic;
+ })(Phaser.Easing || (Phaser.Easing = {}));
+ var Easing = Phaser.Easing;
+})(Phaser || (Phaser = {}));
+var Phaser;
+(function (Phaser) {
+ ///
+ /**
+ * Phaser - Easing
+ *
+ * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
+ *
+ * @version 1.0 - 11th January 2013
+ *
+ * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+ */
+ (function (Easing) {
+ var Sinusoidal = (function () {
+ function Sinusoidal() { }
+ Sinusoidal.In = function In(k) {
+ return 1 - Math.cos(k * Math.PI / 2);
+ };
+ Sinusoidal.Out = function Out(k) {
+ return Math.sin(k * Math.PI / 2);
+ };
+ Sinusoidal.InOut = function InOut(k) {
+ return 0.5 * (1 - Math.cos(Math.PI * k));
+ };
+ return Sinusoidal;
+ })();
+ Easing.Sinusoidal = Sinusoidal;
+ })(Phaser.Easing || (Phaser.Easing = {}));
+ var Easing = Phaser.Easing;
+})(Phaser || (Phaser = {}));
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
+///
/**
-* Phaser - Tween Manager
+* Phaser - Tween
*
-* @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js) converted to TypeScript, patched and integrated into Phaser
+* @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js) converted to TypeScript and integrated into Phaser
*
* @version 1.0 - 11th January 2013
*
-* @author Richard Davey, TypeScript conversion and Phaser integration
-* @author sole / http://soledadpenades.com
-* @author mrdoob / http://mrdoob.com
-* @author Robert Eisele / http://www.xarg.org
-* @author Philippe / http://philippe.elsass.me
-* @author Robert Penner / http://www.robertpenner.com/easing_terms_of_use.html
-* @author Paul Lewis / http://www.aerotwist.com/
-* @author lechecacharro
-* @author Josh Faul / http://jocafa.com/
-* @author egraether / http://egraether.com/
+* @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+*/
+var Phaser;
+(function (Phaser) {
+ var Tween = (function () {
+ function Tween(object, game) {
+ this._object = null;
+ this._pausedTime = 0;
+ this._valuesStart = {
+ };
+ this._valuesEnd = {
+ };
+ this._duration = 1000;
+ this._delayTime = 0;
+ this._startTime = null;
+ this._chainedTweens = [];
+ this._object = object;
+ this._game = game;
+ this._manager = this._game.tweens;
+ this._interpolationFunction = this._game.math.linearInterpolation;
+ this._easingFunction = Phaser.Easing.Linear.None;
+ this.onStart = new Phaser.Signal();
+ this.onUpdate = new Phaser.Signal();
+ this.onComplete = new Phaser.Signal();
+ }
+ Tween.prototype.to = function (properties, duration, ease, autoStart) {
+ if (typeof duration === "undefined") { duration = 1000; }
+ if (typeof ease === "undefined") { ease = null; }
+ if (typeof autoStart === "undefined") { autoStart = false; }
+ this._duration = duration;
+ // If properties isn't an object this will fail, sanity check it here somehow?
+ this._valuesEnd = properties;
+ if(ease !== null) {
+ this._easingFunction = ease;
+ }
+ if(autoStart === true) {
+ return this.start();
+ } else {
+ return this;
+ }
+ };
+ Tween.prototype.start = function () {
+ if(this._game === null || this._object === null) {
+ return;
+ }
+ this._manager.add(this);
+ this.onStart.dispatch(this._object);
+ this._startTime = this._game.time.now + this._delayTime;
+ for(var property in this._valuesEnd) {
+ // This prevents the interpolation of null values or of non-existing properties
+ if(this._object[property] === null || !(property in this._object)) {
+ throw Error('Phaser.Tween interpolation of null value of non-existing property');
+ continue;
+ }
+ // check if an Array was provided as property value
+ if(this._valuesEnd[property] instanceof Array) {
+ if(this._valuesEnd[property].length === 0) {
+ continue;
+ }
+ // create a local copy of the Array with the start value at the front
+ this._valuesEnd[property] = [
+ this._object[property]
+ ].concat(this._valuesEnd[property]);
+ }
+ this._valuesStart[property] = this._object[property];
+ }
+ return this;
+ };
+ Tween.prototype.stop = function () {
+ if(this._manager !== null) {
+ this._manager.remove(this);
+ }
+ return this;
+ };
+ Object.defineProperty(Tween.prototype, "parent", {
+ set: function (value) {
+ this._game = value;
+ this._manager = this._game.tweens;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(Tween.prototype, "delay", {
+ get: function () {
+ return this._delayTime;
+ },
+ set: function (amount) {
+ this._delayTime = amount;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(Tween.prototype, "easing", {
+ get: function () {
+ return this._easingFunction;
+ },
+ set: function (easing) {
+ this._easingFunction = easing;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(Tween.prototype, "interpolation", {
+ get: function () {
+ return this._interpolationFunction;
+ },
+ set: function (interpolation) {
+ this._interpolationFunction = interpolation;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Tween.prototype.chain = function (tween) {
+ this._chainedTweens.push(tween);
+ return this;
+ };
+ Tween.prototype.update = function (time) {
+ if(this._game.paused == true) {
+ if(this._pausedTime == 0) {
+ this._pausedTime = time;
+ }
+ } else {
+ // Ok we aren't paused, but was there some time gained?
+ if(this._pausedTime > 0) {
+ this._startTime += (time - this._pausedTime);
+ this._pausedTime = 0;
+ }
+ }
+ if(time < this._startTime) {
+ return true;
+ }
+ var elapsed = (time - this._startTime) / this._duration;
+ elapsed = elapsed > 1 ? 1 : elapsed;
+ var value = this._easingFunction(elapsed);
+ for(var property in this._valuesStart) {
+ // Add checks for object, array, numeric up front
+ if(this._valuesEnd[property] instanceof Array) {
+ this._object[property] = this._interpolationFunction(this._valuesEnd[property], value);
+ } else {
+ this._object[property] = this._valuesStart[property] + (this._valuesEnd[property] - this._valuesStart[property]) * value;
+ }
+ }
+ this.onUpdate.dispatch(this._object, value);
+ if(elapsed == 1) {
+ this.onComplete.dispatch(this._object);
+ for(var i = 0; i < this._chainedTweens.length; i++) {
+ this._chainedTweens[i].start();
+ }
+ return false;
+ }
+ return true;
+ };
+ return Tween;
+ })();
+ Phaser.Tween = Tween;
+})(Phaser || (Phaser = {}));
+///
+///
+/**
+* Phaser - TweenManager
*
-* @todo
-* 1) Allow for tweening direct numeric values, not just object properties
-* 2) YoYo support
+* The Game has a single instance of the TweenManager through which all Tween objects are created and updated.
+* Tweens are hooked into the game clock and pause system, adjusting based on the game state.
+* TweenManager is based heavily on tween.js by sole (http://soledadpenades.com).
+* I converted it to TypeScript, swapped the callbacks for signals and patched a few issues with regard
+* to properties and completion errors. Please see https://github.com/sole/tween.js for a full list of contributors.
*/
var Phaser;
(function (Phaser) {
@@ -7553,7 +8064,11 @@ var Phaser;
})(Phaser || (Phaser = {}));
///
/**
-* Phaser
+* Phaser - World
+*
+* A game has only one world. The world is an abstract place in which all game objects live. It is not bound
+* by stage limits and can be any size or dimension. You look into the world via cameras and all game objects
+* live within the world at world-based coordinates. By default a world is created the same size as your Stage.
*/
var Phaser;
(function (Phaser) {
@@ -10405,7 +10920,7 @@ var Phaser;
///
///
///
-///
+///
///
///
///
@@ -10424,10 +10939,10 @@ var Phaser;
///
///
/**
-* Phaser
+* Phaser - Game
*
-* Richard Davey (@photonstorm)
-* Adam Saltsman (@ADAMATOMIC) (original Flixel code)
+* This is where the magic happens. The Game object is the heart of your game, providing quick access to common
+* functions and handling the boot process.
*/
var Phaser;
(function (Phaser) {
@@ -10696,591 +11211,91 @@ var Phaser;
})();
Phaser.Game = Game;
})(Phaser || (Phaser = {}));
-var Phaser;
-(function (Phaser) {
- ///
- /**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
- (function (Easing) {
- var Back = (function () {
- function Back() { }
- Back.In = function In(k) {
- var s = 1.70158;
- return k * k * ((s + 1) * k - s);
- };
- Back.Out = function Out(k) {
- var s = 1.70158;
- return --k * k * ((s + 1) * k + s) + 1;
- };
- Back.InOut = function InOut(k) {
- var s = 1.70158 * 1.525;
- if((k *= 2) < 1) {
- return 0.5 * (k * k * ((s + 1) * k - s));
- }
- return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
- };
- return Back;
- })();
- Easing.Back = Back;
- })(Phaser.Easing || (Phaser.Easing = {}));
- var Easing = Phaser.Easing;
-})(Phaser || (Phaser = {}));
-var Phaser;
-(function (Phaser) {
- ///
- /**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
- (function (Easing) {
- var Bounce = (function () {
- function Bounce() { }
- Bounce.In = function In(k) {
- return 1 - Phaser.Easing.Bounce.Out(1 - k);
- };
- Bounce.Out = function Out(k) {
- if(k < (1 / 2.75)) {
- return 7.5625 * k * k;
- } else if(k < (2 / 2.75)) {
- return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
- } else if(k < (2.5 / 2.75)) {
- return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
- } else {
- return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
- }
- };
- Bounce.InOut = function InOut(k) {
- if(k < 0.5) {
- return Phaser.Easing.Bounce.In(k * 2) * 0.5;
- }
- return Phaser.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5;
- };
- return Bounce;
- })();
- Easing.Bounce = Bounce;
- })(Phaser.Easing || (Phaser.Easing = {}));
- var Easing = Phaser.Easing;
-})(Phaser || (Phaser = {}));
-var Phaser;
-(function (Phaser) {
- ///
- /**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
- (function (Easing) {
- var Circular = (function () {
- function Circular() { }
- Circular.In = function In(k) {
- return 1 - Math.sqrt(1 - k * k);
- };
- Circular.Out = function Out(k) {
- return Math.sqrt(1 - (--k * k));
- };
- Circular.InOut = function InOut(k) {
- if((k *= 2) < 1) {
- return -0.5 * (Math.sqrt(1 - k * k) - 1);
- }
- return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
- };
- return Circular;
- })();
- Easing.Circular = Circular;
- })(Phaser.Easing || (Phaser.Easing = {}));
- var Easing = Phaser.Easing;
-})(Phaser || (Phaser = {}));
-var Phaser;
-(function (Phaser) {
- ///
- /**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
- (function (Easing) {
- var Cubic = (function () {
- function Cubic() { }
- Cubic.In = function In(k) {
- return k * k * k;
- };
- Cubic.Out = function Out(k) {
- return --k * k * k + 1;
- };
- Cubic.InOut = function InOut(k) {
- if((k *= 2) < 1) {
- return 0.5 * k * k * k;
- }
- return 0.5 * ((k -= 2) * k * k + 2);
- };
- return Cubic;
- })();
- Easing.Cubic = Cubic;
- })(Phaser.Easing || (Phaser.Easing = {}));
- var Easing = Phaser.Easing;
-})(Phaser || (Phaser = {}));
-var Phaser;
-(function (Phaser) {
- ///
- /**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
- (function (Easing) {
- var Elastic = (function () {
- function Elastic() { }
- Elastic.In = function In(k) {
- var s, a = 0.1, p = 0.4;
- if(k === 0) {
- return 0;
- }
- if(k === 1) {
- return 1;
- }
- if(!a || a < 1) {
- a = 1;
- s = p / 4;
- } else {
- s = p * Math.asin(1 / a) / (2 * Math.PI);
- }
- return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
- };
- Elastic.Out = function Out(k) {
- var s, a = 0.1, p = 0.4;
- if(k === 0) {
- return 0;
- }
- if(k === 1) {
- return 1;
- }
- if(!a || a < 1) {
- a = 1;
- s = p / 4;
- } else {
- s = p * Math.asin(1 / a) / (2 * Math.PI);
- }
- return (a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1);
- };
- Elastic.InOut = function InOut(k) {
- var s, a = 0.1, p = 0.4;
- if(k === 0) {
- return 0;
- }
- if(k === 1) {
- return 1;
- }
- if(!a || a < 1) {
- a = 1;
- s = p / 4;
- } else {
- s = p * Math.asin(1 / a) / (2 * Math.PI);
- }
- if((k *= 2) < 1) {
- return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
- }
- return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
- };
- return Elastic;
- })();
- Easing.Elastic = Elastic;
- })(Phaser.Easing || (Phaser.Easing = {}));
- var Easing = Phaser.Easing;
-})(Phaser || (Phaser = {}));
-var Phaser;
-(function (Phaser) {
- ///
- /**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
- (function (Easing) {
- var Exponential = (function () {
- function Exponential() { }
- Exponential.In = function In(k) {
- return k === 0 ? 0 : Math.pow(1024, k - 1);
- };
- Exponential.Out = function Out(k) {
- return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
- };
- Exponential.InOut = function InOut(k) {
- if(k === 0) {
- return 0;
- }
- if(k === 1) {
- return 1;
- }
- if((k *= 2) < 1) {
- return 0.5 * Math.pow(1024, k - 1);
- }
- return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
- };
- return Exponential;
- })();
- Easing.Exponential = Exponential;
- })(Phaser.Easing || (Phaser.Easing = {}));
- var Easing = Phaser.Easing;
-})(Phaser || (Phaser = {}));
-var Phaser;
-(function (Phaser) {
- ///
- /**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
- (function (Easing) {
- var Linear = (function () {
- function Linear() { }
- Linear.None = function None(k) {
- return k;
- };
- return Linear;
- })();
- Easing.Linear = Linear;
- })(Phaser.Easing || (Phaser.Easing = {}));
- var Easing = Phaser.Easing;
-})(Phaser || (Phaser = {}));
-var Phaser;
-(function (Phaser) {
- ///
- /**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
- (function (Easing) {
- var Quadratic = (function () {
- function Quadratic() { }
- Quadratic.In = function In(k) {
- return k * k;
- };
- Quadratic.Out = function Out(k) {
- return k * (2 - k);
- };
- Quadratic.InOut = function InOut(k) {
- if((k *= 2) < 1) {
- return 0.5 * k * k;
- }
- return -0.5 * (--k * (k - 2) - 1);
- };
- return Quadratic;
- })();
- Easing.Quadratic = Quadratic;
- })(Phaser.Easing || (Phaser.Easing = {}));
- var Easing = Phaser.Easing;
-})(Phaser || (Phaser = {}));
-var Phaser;
-(function (Phaser) {
- ///
- /**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
- (function (Easing) {
- var Quartic = (function () {
- function Quartic() { }
- Quartic.In = function In(k) {
- return k * k * k * k;
- };
- Quartic.Out = function Out(k) {
- return 1 - (--k * k * k * k);
- };
- Quartic.InOut = function InOut(k) {
- if((k *= 2) < 1) {
- return 0.5 * k * k * k * k;
- }
- return -0.5 * ((k -= 2) * k * k * k - 2);
- };
- return Quartic;
- })();
- Easing.Quartic = Quartic;
- })(Phaser.Easing || (Phaser.Easing = {}));
- var Easing = Phaser.Easing;
-})(Phaser || (Phaser = {}));
-var Phaser;
-(function (Phaser) {
- ///
- /**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
- (function (Easing) {
- var Quintic = (function () {
- function Quintic() { }
- Quintic.In = function In(k) {
- return k * k * k * k * k;
- };
- Quintic.Out = function Out(k) {
- return --k * k * k * k * k + 1;
- };
- Quintic.InOut = function InOut(k) {
- if((k *= 2) < 1) {
- return 0.5 * k * k * k * k * k;
- }
- return 0.5 * ((k -= 2) * k * k * k * k + 2);
- };
- return Quintic;
- })();
- Easing.Quintic = Quintic;
- })(Phaser.Easing || (Phaser.Easing = {}));
- var Easing = Phaser.Easing;
-})(Phaser || (Phaser = {}));
-var Phaser;
-(function (Phaser) {
- ///
- /**
- * Phaser - Easing
- *
- * @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js)
- *
- * @version 1.0 - 11th January 2013
- *
- * @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
- */
- (function (Easing) {
- var Sinusoidal = (function () {
- function Sinusoidal() { }
- Sinusoidal.In = function In(k) {
- return 1 - Math.cos(k * Math.PI / 2);
- };
- Sinusoidal.Out = function Out(k) {
- return Math.sin(k * Math.PI / 2);
- };
- Sinusoidal.InOut = function InOut(k) {
- return 0.5 * (1 - Math.cos(Math.PI * k));
- };
- return Sinusoidal;
- })();
- Easing.Sinusoidal = Sinusoidal;
- })(Phaser.Easing || (Phaser.Easing = {}));
- var Easing = Phaser.Easing;
-})(Phaser || (Phaser = {}));
///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
+///
/**
-* Phaser - Tween
+* Phaser - Sound
*
-* @desc Based heavily on tween.js by sole (https://github.com/sole/tween.js) converted to TypeScript and integrated into Phaser
-*
-* @version 1.0 - 11th January 2013
-*
-* @author Richard Davey, TypeScript conversion and Phaser integration. See Phaser.TweenManager for the full tween.js author list
+* A Sound file, used by the Game.SoundManager for playback.
*/
var Phaser;
(function (Phaser) {
- var Tween = (function () {
- function Tween(object, game) {
- this._object = null;
- this._pausedTime = 0;
- this._valuesStart = {
- };
- this._valuesEnd = {
- };
- this._duration = 1000;
- this._delayTime = 0;
- this._startTime = null;
- this._chainedTweens = [];
- this._object = object;
- this._game = game;
- this._manager = this._game.tweens;
- this._interpolationFunction = this._game.math.linearInterpolation;
- this._easingFunction = Phaser.Easing.Linear.None;
- this.onStart = new Phaser.Signal();
- this.onUpdate = new Phaser.Signal();
- this.onComplete = new Phaser.Signal();
- }
- Tween.prototype.to = function (properties, duration, ease, autoStart) {
- if (typeof duration === "undefined") { duration = 1000; }
- if (typeof ease === "undefined") { ease = null; }
- if (typeof autoStart === "undefined") { autoStart = false; }
- this._duration = duration;
- // If properties isn't an object this will fail, sanity check it here somehow?
- this._valuesEnd = properties;
- if(ease !== null) {
- this._easingFunction = ease;
+ var Sound = (function () {
+ function Sound(context, gainNode, data, volume, loop) {
+ if (typeof volume === "undefined") { volume = 1; }
+ if (typeof loop === "undefined") { loop = false; }
+ this.loop = false;
+ this.isPlaying = false;
+ this.isDecoding = false;
+ this._context = context;
+ this._gainNode = gainNode;
+ this._buffer = data;
+ this._volume = volume;
+ this.loop = loop;
+ // Local volume control
+ if(this._context !== null) {
+ this._localGainNode = this._context.createGainNode();
+ this._localGainNode.connect(this._gainNode);
+ this._localGainNode.gain.value = this._volume;
}
- if(autoStart === true) {
- return this.start();
+ if(this._buffer === null) {
+ this.isDecoding = true;
} else {
- return this;
+ this.play();
}
+ }
+ Sound.prototype.setDecodedBuffer = function (data) {
+ this._buffer = data;
+ this.isDecoding = false;
+ this.play();
};
- Tween.prototype.start = function () {
- if(this._game === null || this._object === null) {
+ Sound.prototype.play = function () {
+ if(this._buffer === null || this.isDecoding === true) {
return;
}
- this._manager.add(this);
- this.onStart.dispatch(this._object);
- this._startTime = this._game.time.now + this._delayTime;
- for(var property in this._valuesEnd) {
- // This prevents the interpolation of null values or of non-existing properties
- if(this._object[property] === null || !(property in this._object)) {
- throw Error('Phaser.Tween interpolation of null value of non-existing property');
- continue;
- }
- // check if an Array was provided as property value
- if(this._valuesEnd[property] instanceof Array) {
- if(this._valuesEnd[property].length === 0) {
- continue;
- }
- // create a local copy of the Array with the start value at the front
- this._valuesEnd[property] = [
- this._object[property]
- ].concat(this._valuesEnd[property]);
- }
- this._valuesStart[property] = this._object[property];
+ this._sound = this._context.createBufferSource();
+ this._sound.buffer = this._buffer;
+ this._sound.connect(this._localGainNode);
+ if(this.loop) {
+ this._sound.loop = true;
}
- return this;
+ this._sound.noteOn(0)// the zero is vitally important, crashes iOS6 without it
+ ;
+ this.duration = this._sound.buffer.duration;
+ this.isPlaying = true;
};
- Tween.prototype.stop = function () {
- if(this._manager !== null) {
- this._manager.remove(this);
+ Sound.prototype.stop = function () {
+ if(this.isPlaying === true) {
+ this.isPlaying = false;
+ this._sound.noteOff(0);
}
- return this;
};
- Object.defineProperty(Tween.prototype, "parent", {
+ Sound.prototype.mute = function () {
+ this._localGainNode.gain.value = 0;
+ };
+ Sound.prototype.unmute = function () {
+ this._localGainNode.gain.value = this._volume;
+ };
+ Object.defineProperty(Sound.prototype, "volume", {
+ get: function () {
+ return this._volume;
+ },
set: function (value) {
- this._game = value;
- this._manager = this._game.tweens;
+ this._volume = value;
+ this._localGainNode.gain.value = this._volume;
},
enumerable: true,
configurable: true
});
- Object.defineProperty(Tween.prototype, "delay", {
- get: function () {
- return this._delayTime;
- },
- set: function (amount) {
- this._delayTime = amount;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Tween.prototype, "easing", {
- get: function () {
- return this._easingFunction;
- },
- set: function (easing) {
- this._easingFunction = easing;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Tween.prototype, "interpolation", {
- get: function () {
- return this._interpolationFunction;
- },
- set: function (interpolation) {
- this._interpolationFunction = interpolation;
- },
- enumerable: true,
- configurable: true
- });
- Tween.prototype.chain = function (tween) {
- this._chainedTweens.push(tween);
- return this;
- };
- Tween.prototype.update = function (time) {
- if(this._game.paused == true) {
- if(this._pausedTime == 0) {
- this._pausedTime = time;
- }
- } else {
- // Ok we aren't paused, but was there some time gained?
- if(this._pausedTime > 0) {
- this._startTime += (time - this._pausedTime);
- this._pausedTime = 0;
- }
- }
- if(time < this._startTime) {
- return true;
- }
- var elapsed = (time - this._startTime) / this._duration;
- elapsed = elapsed > 1 ? 1 : elapsed;
- var value = this._easingFunction(elapsed);
- for(var property in this._valuesStart) {
- // Add checks for object, array, numeric up front
- if(this._valuesEnd[property] instanceof Array) {
- this._object[property] = this._interpolationFunction(this._valuesEnd[property], value);
- } else {
- this._object[property] = this._valuesStart[property] + (this._valuesEnd[property] - this._valuesStart[property]) * value;
- }
- }
- this.onUpdate.dispatch(this._object, value);
- if(elapsed == 1) {
- this.onComplete.dispatch(this._object);
- for(var i = 0; i < this._chainedTweens.length; i++) {
- this._chainedTweens[i].start();
- }
- return false;
- }
- return true;
- };
- return Tween;
+ return Sound;
})();
- Phaser.Tween = Tween;
+ Phaser.Sound = Sound;
})(Phaser || (Phaser = {}));
///
/**
-* Phaser
+* Phaser - State
+*
+* This is a base State class which can be extended if you are creating your game using TypeScript.
*/
var Phaser;
(function (Phaser) {