Updated docs for 1.1.2 release.

This commit is contained in:
photonstorm
2013-11-01 18:16:52 +00:00
parent eb95ce231b
commit 3e9777e6f4
150 changed files with 6188 additions and 2252 deletions
+218 -19
View File
@@ -58,10 +58,6 @@
<a href="Phaser.BitmapText.html">BitmapText</a>
</li>
<li>
<a href="Phaser.Bullet.html">Bullet</a>
</li>
<li>
<a href="Phaser.Button.html">Button</a>
</li>
@@ -465,6 +461,13 @@ Phaser.Group = function (game, parent, name, useStage) {
*/
this.scale = new Phaser.Point(1, 1);
/**
* The cursor is a simple way to iterate through the objects in a Group using the Group.next and Group.previous functions.
* The cursor is set to the first child added to the Group and doesn't change unless you call next, previous or set it directly with Group.cursor.
* @property {any} cursor - The current display object that the Group cursor is pointing to.
*/
this.cursor = null;
};
Phaser.Group.prototype = {
@@ -494,6 +497,11 @@ Phaser.Group.prototype = {
this._container.addChild(child);
child.updateTransform();
if (this.cursor === null)
{
this.cursor = child;
}
}
return child;
@@ -523,6 +531,11 @@ Phaser.Group.prototype = {
this._container.addChildAt(child, index);
child.updateTransform();
if (this.cursor === null)
{
this.cursor = child;
}
}
return child;
@@ -575,6 +588,11 @@ Phaser.Group.prototype = {
child.updateTransform();
if (this.cursor === null)
{
this.cursor = child;
}
return child;
},
@@ -611,6 +629,55 @@ Phaser.Group.prototype = {
this._container.addChild(child);
child.updateTransform();
if (this.cursor === null)
{
this.cursor = child;
}
}
},
/**
* Advances the Group cursor to the next object in the Group. If it's at the end of the Group it wraps around to the first object.
*
* @method Phaser.Group#next
*/
next: function () {
if (this.cursor)
{
// Wrap the cursor?
if (this.cursor == this._container.last)
{
this.cursor = this._container._iNext;
}
else
{
this.cursor = this.cursor._iNext;
}
}
},
/**
* Moves the Group cursor to the previous object in the Group. If it's at the start of the Group it wraps around to the last object.
*
* @method Phaser.Group#previous
*/
previous: function () {
if (this.cursor)
{
// Wrap the cursor?
if (this.cursor == this._container._iNext)
{
this.cursor = this._container.last;
}
else
{
this.cursor = this.cursor._iPrev;
}
}
},
@@ -801,8 +868,14 @@ Phaser.Group.prototype = {
this._container.removeChild(oldChild);
this._container.addChildAt(newChild, index);
newChild.events.onAddedToGroup.dispatch(newChild, this);
newChild.updateTransform();
if (this.cursor == oldChild)
{
this.cursor = this._container._iNext;
}
}
},
@@ -830,7 +903,9 @@ Phaser.Group.prototype = {
// 3 = Multiply
// 4 = Divide
if (key.length == 1)
var len = key.length;
if (len == 1)
{
if (operation == 0) { child[key[0]] = value; }
else if (operation == 1) { child[key[0]] += value; }
@@ -838,7 +913,7 @@ Phaser.Group.prototype = {
else if (operation == 3) { child[key[0]] *= value; }
else if (operation == 4) { child[key[0]] /= value; }
}
else if (key.length == 2)
else if (len == 2)
{
if (operation == 0) { child[key[0]][key[1]] = value; }
else if (operation == 1) { child[key[0]][key[1]] += value; }
@@ -846,7 +921,7 @@ Phaser.Group.prototype = {
else if (operation == 3) { child[key[0]][key[1]] *= value; }
else if (operation == 4) { child[key[0]][key[1]] /= value; }
}
else if (key.length == 3)
else if (len == 3)
{
if (operation == 0) { child[key[0]][key[1]][key[2]] = value; }
else if (operation == 1) { child[key[0]][key[1]][key[2]] += value; }
@@ -854,7 +929,7 @@ Phaser.Group.prototype = {
else if (operation == 3) { child[key[0]][key[1]][key[2]] *= value; }
else if (operation == 4) { child[key[0]][key[1]][key[2]] /= value; }
}
else if (key.length == 4)
else if (len == 4)
{
if (operation == 0) { child[key[0]][key[1]][key[2]][key[3]] = value; }
else if (operation == 1) { child[key[0]][key[1]][key[2]][key[3]] += value; }
@@ -1003,32 +1078,122 @@ Phaser.Group.prototype = {
},
/**
* Calls a function on all of the children that have exists=true in this Group.
*
* @method Phaser.Group#callbackFromArray
* @param {object} child - The object to inspect.
* @param {array} callback - The array of function names.
* @param {number} length - The size of the array (pre-calculated in callAll).
* @protected
*/
callbackFromArray: function (child, callback, length) {
// Kinda looks like a Christmas tree
if (length == 1)
{
if (child[callback[0]])
{
return child[callback[0]];
}
}
else if (length == 2)
{
if (child[callback[0]][callback[1]])
{
return child[callback[0]][callback[1]];
}
}
else if (length == 3)
{
if (child[callback[0]][callback[1]][callback[2]])
{
return child[callback[0]][callback[1]][callback[2]];
}
}
else if (length == 4)
{
if (child[callback[0]][callback[1]][callback[2]][callback[3]])
{
return child[callback[0]][callback[1]][callback[2]][callback[3]];
}
}
else
{
if (child[callback])
{
return child[callback];
}
}
return false;
},
/**
* Calls a function on all of the children regardless if they are dead or alive (see callAllExists if you need control over that)
* After the callback parameter you can add as many extra parameters as you like, which will all be passed to the child.
* After the method parameter you can add as many extra parameters as you like, which will all be passed to the child.
*
* @method Phaser.Group#callAll
* @param {function} callback - The function that exists on the children that will be called.
* @param {...*} parameter - Additional parameters that will be passed to the callback.
* @param {string} method - A string containing the name of the function that will be called. The function must exist on the child.
* @param {string} [context=''] - A string containing the context under which the method will be executed. Leave to '' to default to the child.
* @param {...*} parameter - Additional parameters that will be passed to the method.
*/
callAll: function (callback) {
callAll: function (method, context) {
var args = Array.prototype.splice.call(arguments, 1);
if (typeof method === 'undefined')
{
return;
}
// Extract the method into an array
method = method.split('.');
var methodLength = method.length;
if (typeof context === 'undefined')
{
context = null;
}
else
{
// Extract the context into an array
if (typeof context === 'string')
{
context = context.split('.');
var contextLength = context.length;
}
}
var args = Array.prototype.splice.call(arguments, 2);
var callback = null;
if (this._container.children.length > 0 && this._container.first._iNext)
{
var currentNode = this._container.first._iNext;
var child = this._container.first._iNext;
do
{
if (currentNode[callback])
callback = this.callbackFromArray(child, method, methodLength);
if (context && callback)
{
currentNode[callback].apply(currentNode, args);
callbackContext = this.callbackFromArray(child, context, contextLength);
if (callback)
{
callback.apply(callbackContext, args);
}
}
else if (callback)
{
callback.apply(child, args);
}
currentNode = currentNode._iNext;
child = child._iNext;
}
while (currentNode != this._container.last._iNext)
while (child != this._container.last._iNext)
}
@@ -1338,6 +1503,18 @@ Phaser.Group.prototype = {
this._container.removeChild(child);
if (this.cursor == child)
{
if (this._container._iNext)
{
this.cursor = this._container._iNext;
}
else
{
this.cursor = null;
}
}
child.group = null;
},
@@ -1365,6 +1542,8 @@ Phaser.Group.prototype = {
}
while (this._container.children.length > 0);
this.cursor = null;
},
/**
@@ -1391,6 +1570,18 @@ Phaser.Group.prototype = {
var child = this._container.children[i];
child.events.onRemovedFromGroup.dispatch(child, this);
this._container.removeChild(child);
if (this.cursor == child)
{
if (this._container._iNext)
{
this.cursor = this._container._iNext;
}
else
{
this.cursor = null;
}
}
}
},
@@ -1412,6 +1603,8 @@ Phaser.Group.prototype = {
this.exists = false;
this.cursor = null;
},
/**
@@ -1449,6 +1642,12 @@ Phaser.Group.prototype = {
do
{
var name = displayObject.name || '*';
if (this.cursor == displayObject)
{
var name = '> ' + name;
}
var nameNext = '-';
var namePrev = '-';
var nameFirst = '-';
@@ -1656,7 +1855,7 @@ Object.defineProperty(Phaser.Group.prototype, "alpha", {
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
on Fri Oct 25 2013 17:05:24 GMT+0100 (BST) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
on Fri Nov 01 2013 18:16:08 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>