Skip to content

Commit

Permalink
Tidying up the repo and adding in new documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
photonstorm committed Oct 23, 2013
1 parent 4a51ac4 commit ffd5ddc
Show file tree
Hide file tree
Showing 375 changed files with 5,008 additions and 33,315 deletions.
23 changes: 20 additions & 3 deletions docs2/out/Animation.js.html → docs/Animation.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
*/
this.looped = looped;

/**
* @property {boolean} looped - The loop state of the Animation.
*/
this.killOnComplete = false;

/**
* @property {boolean} isFinished - The finished state of the Animation. Set to true once playback completes, false during playback.
* @default
Expand Down Expand Up @@ -443,10 +448,11 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
* @method Phaser.Animation#play
* @memberof Phaser.Animation
* @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
* @param {boolean} [loop=null] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
* @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
* @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed.
* @return {Phaser.Animation} - A reference to this Animation instance.
*/
play: function (frameRate, loop) {
play: function (frameRate, loop, killOnComplete) {

if (typeof frameRate === 'number')
{
Expand All @@ -460,6 +466,12 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
this.looped = loop;
}

if (typeof killOnComplete !== 'undefined')
{
// Remove the parent sprite once the animation has finished?
this.killOnComplete = killOnComplete;
}

this.isPlaying = true;
this.isFinished = false;

Expand Down Expand Up @@ -621,6 +633,11 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
this._parent.events.onAnimationComplete.dispatch(this._parent, this);
}

if (this.killOnComplete)
{
this._parent.kill();
}

}

};
Expand Down Expand Up @@ -765,7 +782,7 @@ <h1 class="page-title">Source: animation/Animation.js</h1>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a>
on Thu Oct 03 2013 02:35:44 GMT+0100 (BST) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
on Wed Oct 23 2013 13:51:58 GMT+0100 (BST) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@ <h1 class="page-title">Source: animation/AnimationManager.js</h1>
*/
this.updateIfVisible = true;

/**
* @property {boolean} isLoaded - Set to true once animation data has been loaded.
* @default
*/
this.isLoaded = false;

/**
* @property {Phaser.FrameData} _frameData - A temp. var for holding the currently playing Animations FrameData.
* @private
Expand Down Expand Up @@ -394,6 +400,7 @@ <h1 class="page-title">Source: animation/AnimationManager.js</h1>

this._frameData = frameData;
this.frame = 0;
this.isLoaded = true;

},

Expand All @@ -420,7 +427,19 @@ <h1 class="page-title">Source: animation/AnimationManager.js</h1>
frameRate = frameRate || 60;

if (typeof loop === 'undefined') { loop = false; }
if (typeof useNumericIndex === 'undefined') { useNumericIndex = true; }

// If they didn't set the useNumericIndex then let's at least try and guess it
if (typeof useNumericIndex === 'undefined')
{
if (frames && typeof frames[0] === 'number')
{
useNumericIndex = true;
}
else
{
useNumericIndex = false;
}
}

// Create the signals the AnimationManager will emit
if (this.sprite.events.onAnimationStart == null)
Expand Down Expand Up @@ -484,24 +503,25 @@ <h1 class="page-title">Source: animation/AnimationManager.js</h1>
* @method Phaser.AnimationManager#play
* @param {string} name - The name of the animation to be played, e.g. "fire", "walk", "jump".
* @param {number} [frameRate=null] - The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
* @param {boolean} [loop=null] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
* @param {boolean} [loop=false] - Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
* @param {boolean} [killOnComplete=false] - If set to true when the animation completes (only happens if loop=false) the parent Sprite will be killed.
* @return {Phaser.Animation} A reference to playing Animation instance.
*/
play: function (name, frameRate, loop) {
play: function (name, frameRate, loop, killOnComplete) {

if (this._anims[name])
{
if (this.currentAnim == this._anims[name])
{
if (this.currentAnim.isPlaying == false)
{
return this.currentAnim.play(frameRate, loop);
return this.currentAnim.play(frameRate, loop, killOnComplete);
}
}
else
{
this.currentAnim = this._anims[name];
return this.currentAnim.play(frameRate, loop);
return this.currentAnim.play(frameRate, loop, killOnComplete);
}
}

Expand Down Expand Up @@ -562,6 +582,18 @@ <h1 class="page-title">Source: animation/AnimationManager.js</h1>

},

/**
* Refreshes the current frame data back to the parent Sprite and also resets the texture data.
*
* @method Phaser.AnimationManager#refreshFrame
*/
refreshFrame: function () {

this.sprite.currentFrame = this.currentFrame;
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);

},

/**
* Destroys all references this AnimationManager contains. Sets the _anims to a new object and nulls the current animation.
*
Expand Down Expand Up @@ -650,7 +682,7 @@ <h1 class="page-title">Source: animation/AnimationManager.js</h1>

set: function (value) {

if (this._frameData && this._frameData.getFrame(value) !== null)
if (typeof value === 'number' && this._frameData && this._frameData.getFrame(value) !== null)
{
this.currentFrame = this._frameData.getFrame(value);
this._frameIndex = value;
Expand Down Expand Up @@ -679,7 +711,7 @@ <h1 class="page-title">Source: animation/AnimationManager.js</h1>

set: function (value) {

if (this._frameData && this._frameData.getFrameByName(value) !== null)
if (typeof value === 'string' && this._frameData && this._frameData.getFrameByName(value) !== null)
{
this.currentFrame = this._frameData.getFrameByName(value);
this._frameIndex = this.currentFrame.index;
Expand Down Expand Up @@ -714,7 +746,7 @@ <h1 class="page-title">Source: animation/AnimationManager.js</h1>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a>
on Thu Oct 03 2013 02:35:44 GMT+0100 (BST) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
on Wed Oct 23 2013 13:51:58 GMT+0100 (BST) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ <h1 class="page-title">Source: animation/AnimationParser.js</h1>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a>
on Thu Oct 03 2013 02:35:44 GMT+0100 (BST) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
on Wed Oct 23 2013 13:51:58 GMT+0100 (BST) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
Expand Down
125 changes: 93 additions & 32 deletions docs2/out/Cache.js.html → docs/Cache.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@ <h1 class="page-title">Source: loader/Cache.js</h1>
*/
this._tilemaps = {};

/**
* @property {object} _tilesets - Tileset key-value container.
* @private
*/
this._tilesets = {};

this.addDefaultImage();

Expand Down Expand Up @@ -441,22 +446,44 @@ <h1 class="page-title">Source: loader/Cache.js</h1>

},

/**
* Add a new tile set in to the cache.
*
* @method Phaser.Cache#addTileset
* @param {string} key - The unique key by which you will reference this object.
* @param {string} url - URL of this tile set file.
* @param {object} data - Extra tile set data.
* @param {number} tileWidth - Width of the sprite sheet.
* @param {number} tileHeight - Height of the sprite sheet.
* @param {number} tileMax - How many tiles stored in the sprite sheet.
* @param {number} [tileMargin=0] - If the tiles have been drawn with a margin, specify the amount here.
* @param {number} [tileSpacing=0] - If the tiles have been drawn with spacing between them, specify the amount here.
*/
addTileset: function (key, url, data, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing) {

this._tilesets[key] = { url: url, data: data, tileWidth: tileWidth, tileHeight: tileHeight, tileMargin: tileMargin, tileSpacing: tileSpacing };

PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);

this._tilesets[key].tileData = Phaser.TilemapParser.tileset(this.game, key, tileWidth, tileHeight, tileMax, tileMargin, tileSpacing);

},

/**
* Add a new tilemap.
*
* @method Phaser.Cache#addTilemap
* @param {string} key - The unique key by which you will reference this object.
* @param {string} url - URL of the tilemap image.
* @param {object} data - Tilemap data.
* @param {object} mapData - The tilemap data object.
* @param {number} format - The format of the tilemap data.
*/
addTilemap: function (key, url, data, mapData, format) {
addTilemap: function (key, url, mapData, format) {

this._tilemaps[key] = { url: url, data: data, spriteSheet: true, mapData: mapData, format: format };
this._tilemaps[key] = { url: url, data: mapData, format: format };

PIXI.BaseTextureCache[key] = new PIXI.BaseTexture(data);
PIXI.TextureCache[key] = new PIXI.Texture(PIXI.BaseTextureCache[key]);
this._tilemaps[key].layers = Phaser.TilemapParser.parse(this.game, mapData, format);

},

Expand Down Expand Up @@ -520,16 +547,31 @@ <h1 class="page-title">Source: loader/Cache.js</h1>
*/
addDefaultImage: function () {

this._images['__default'] = { url: null, data: null, spriteSheet: false };
var img = new Image();
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==";

this._images['__default'] = { url: null, data: img, spriteSheet: false };
this._images['__default'].frame = new Phaser.Frame(0, 0, 0, 32, 32, '', '');

var base = new PIXI.BaseTexture();
base.width = 32;
base.height = 32;
base.hasLoaded = true; // avoids a hanging event listener
PIXI.BaseTextureCache['__default'] = new PIXI.BaseTexture(img);
PIXI.TextureCache['__default'] = new PIXI.Texture(PIXI.BaseTextureCache['__default']);

PIXI.BaseTextureCache['__default'] = base;
PIXI.TextureCache['__default'] = new PIXI.Texture(base);
},

/**
* Add a new text data.
*
* @method Phaser.Cache#addText
* @param {string} key - Asset key for the text data.
* @param {string} url - URL of this text data file.
* @param {object} data - Extra text data.
*/
addText: function (key, url, data) {

this._text[key] = {
url: url,
data: data
};

},

Expand Down Expand Up @@ -641,23 +683,6 @@ <h1 class="page-title">Source: loader/Cache.js</h1>
this._sounds[key].decoded = true;
this._sounds[key].isDecoding = false;

},

/**
* Add a new text data.
*
* @method Phaser.Cache#addText
* @param {string} key - Asset key for the text data.
* @param {string} url - URL of this text data file.
* @param {object} data - Extra text data.
*/
addText: function (key, url, data) {

this._text[key] = {
url: url,
data: data
};

},

/**
Expand Down Expand Up @@ -712,14 +737,50 @@ <h1 class="page-title">Source: loader/Cache.js</h1>
return null;
},

/**
* Get tile set image data by key.
*
* @method Phaser.Cache#getTileSetImage
* @param {string} key - Asset key of the image you want.
* @return {object} The image data you want.
*/
getTilesetImage: function (key) {

if (this._tilesets[key])
{
return this._tilesets[key].data;
}

return null;

},

/**
* Get tile set image data by key.
*
* @method Phaser.Cache#getTileset
* @param {string} key - Asset key of the image you want.
* @return {Phaser.Tileset} The tileset data. The tileset image is in the data property, the tile data in tileData.
*/
getTileset: function (key) {

if (this._tilesets[key])
{
return this._tilesets[key].tileData;
}

return null;

},

/**
* Get tilemap data by key.
*
* @method Phaser.Cache#getTilemap
* @param {string} key - Asset key of the tilemap you want.
* @return {Phaser.Tilemap} The tilemap data. The tileset image is in the data property, the map data in mapData.
* @return {Object} The tilemap data. The tileset image is in the data property, the map data in mapData.
*/
getTilemap: function (key) {
getTilemapData: function (key) {

if (this._tilemaps[key])
{
Expand Down Expand Up @@ -1077,7 +1138,7 @@ <h1 class="page-title">Source: loader/Cache.js</h1>

<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0-dev</a>
on Thu Oct 03 2013 02:35:44 GMT+0100 (BST) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
on Wed Oct 23 2013 13:51:58 GMT+0100 (BST) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
Expand Down
Loading

0 comments on commit ffd5ddc

Please sign in to comment.