mirror of
https://github.com/wassname/phaser.git
synced 2026-08-12 12:20:38 +08:00
Updated doc files.
This commit is contained in:
+203
-58
@@ -90,6 +90,10 @@
|
||||
<a href="Phaser.Device.html">Device</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.DOMSprite.html">DOMSprite</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Easing.html">Easing</a>
|
||||
</li>
|
||||
@@ -162,6 +166,14 @@
|
||||
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Gamepad.html">Gamepad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.GamepadButton.html">GamepadButton</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Graphics.html">Graphics</a>
|
||||
</li>
|
||||
@@ -186,6 +198,10 @@
|
||||
<a href="Phaser.Keyboard.html">Keyboard</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Line.html">Line</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.LinkedList.html">LinkedList</a>
|
||||
</li>
|
||||
@@ -278,6 +294,10 @@
|
||||
<a href="Phaser.Signal.html">Signal</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.SinglePad.html">SinglePad</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Sound.html">Sound</a>
|
||||
</li>
|
||||
@@ -342,6 +362,10 @@
|
||||
<a href="Phaser.Timer.html">Timer</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.TimerEvent.html">TimerEvent</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="Phaser.Touch.html">Touch</a>
|
||||
</li>
|
||||
@@ -374,36 +398,6 @@
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<li class="dropdown">
|
||||
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
|
||||
class="caret"></b></a>
|
||||
|
||||
<ul class="dropdown-menu ">
|
||||
|
||||
<li>
|
||||
<a href="global.html#bottom">bottom</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#HEXtoRGB">HEXtoRGB</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#render">render</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#renderXY">renderXY</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="global.html#right">right</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -423,7 +417,7 @@
|
||||
<article>
|
||||
<pre class="sunlight-highlight-javascript linenums">/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
@@ -750,7 +744,7 @@ Phaser.Math = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Find the angle of a segment from (x1, y1) -> (x2, y2 ).
|
||||
* Find the angle of a segment from (x1, y1) -> (x2, y2).
|
||||
* @method Phaser.Math#angleBetween
|
||||
* @param {number} x1
|
||||
* @param {number} y1
|
||||
@@ -763,24 +757,58 @@ Phaser.Math = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Set an angle within the bounds of -π toπ.
|
||||
* @method Phaser.Math#normalizeAngle
|
||||
* @param {number} angle
|
||||
* @param {boolean} radians - True if angle size is expressed in radians.
|
||||
* @return {number}
|
||||
* Reverses an angle.
|
||||
* @method Phaser.Math#reverseAngle
|
||||
* @param {number} angleRad - The angle to reverse, in radians.
|
||||
* @return {number} Returns the reverse angle, in radians.
|
||||
*/
|
||||
normalizeAngle: function (angle, radians) {
|
||||
reverseAngle: function (angleRad) {
|
||||
return this.normalizeAngle(angleRad + Math.PI, true);
|
||||
},
|
||||
|
||||
if (typeof radians === "undefined") { radians = true; }
|
||||
/**
|
||||
* Normalizes an angle to the [0,2pi) range.
|
||||
* @method Phaser.Math#normalizeAngle
|
||||
* @param {number} angleRad - The angle to normalize, in radians.
|
||||
* @return {number} Returns the angle, fit within the [0,2pi] range, in radians.
|
||||
*/
|
||||
normalizeAngle: function (angleRad) {
|
||||
|
||||
var rd = (radians) ? Math.PI : 180;
|
||||
return this.wrap(angle, -rd, rd);
|
||||
angleRad = angleRad % (2 * Math.PI);
|
||||
return angleRad >= 0 ? angleRad : angleRad + 2 * Math.PI;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Closest angle between two angles from a1 to a2
|
||||
* absolute value the return for exact angle
|
||||
* Normalizes a latitude to the [-90,90] range. Latitudes above 90 or below -90 are capped, not wrapped.
|
||||
* @method Phaser.Math#normalizeLatitude
|
||||
* @param {number} lat - The latitude to normalize, in degrees.
|
||||
* @return {number} Returns the latitude, fit within the [-90,90] range.
|
||||
*/
|
||||
normalizeLatitude: function (lat) {
|
||||
return Math.max(-90, Math.min(90, lat));
|
||||
},
|
||||
|
||||
/**
|
||||
* Normalizes a longitude to the [-180,180] range. Longitudes above 180 or below -180 are wrapped.
|
||||
* @method Phaser.Math#normalizeLongitude
|
||||
* @param {number} lng - The longitude to normalize, in degrees.
|
||||
* @return {number} Returns the longitude, fit within the [-180,180] range.
|
||||
*/
|
||||
normalizeLongitude: function (lng) {
|
||||
|
||||
if (lng % 360 == 180)
|
||||
{
|
||||
return 180;
|
||||
}
|
||||
|
||||
lng = lng % 360;
|
||||
return lng < -180 ? lng + 360 : lng > 180 ? lng - 360 : lng;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Closest angle between two angles from a1 to a2 absolute value the return for exact angle
|
||||
* @method Phaser.Math#nearestAngleBetween
|
||||
* @param {number} a1
|
||||
* @param {number} a2
|
||||
@@ -934,13 +962,13 @@ Phaser.Math = {
|
||||
|
||||
/**
|
||||
* Ensures that the value always stays between min and max, by wrapping the value around.
|
||||
* <p>max should be larger than min, or the function will return 0</p>
|
||||
* max should be larger than min, or the function will return 0.
|
||||
*
|
||||
* @method Phaser.Math#wrap
|
||||
* @param value The value to wrap
|
||||
* @param min The minimum the value is allowed to be
|
||||
* @param max The maximum the value is allowed to be
|
||||
* @return {number} The wrapped value
|
||||
* @param {number} value - The value to wrap.
|
||||
* @param {number} min - The minimum the value is allowed to be.
|
||||
* @param {number} max - The maximum the value is allowed to be.
|
||||
* @return {number} The wrapped value.
|
||||
*/
|
||||
wrap: function (value, min, max) {
|
||||
|
||||
@@ -1049,7 +1077,7 @@ Phaser.Math = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Significantly faster version of Math.min
|
||||
* Updated version of Math.min that can be passed either an array of numbers or the numbers as parameters.
|
||||
* See http://jsperf.com/math-s-min-max-vs-homemade/5
|
||||
*
|
||||
* @method Phaser.Math#min
|
||||
@@ -1057,15 +1085,113 @@ Phaser.Math = {
|
||||
*/
|
||||
min: function () {
|
||||
|
||||
for (var i =1 , min = 0, len = arguments.length; i < len; i++)
|
||||
if (arguments.length === 1 && typeof arguments[0] === 'object')
|
||||
{
|
||||
if (arguments[i] < arguments[min])
|
||||
var data = arguments[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = arguments;
|
||||
}
|
||||
|
||||
for (var i = 1, min = 0, len = data.length; i < len; i++)
|
||||
{
|
||||
if (data[i] < data[min])
|
||||
{
|
||||
min = i;
|
||||
}
|
||||
}
|
||||
|
||||
return arguments[min];
|
||||
return data[min];
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Updated version of Math.max that can be passed either an array of numbers or the numbers as parameters.
|
||||
*
|
||||
* @method Phaser.Math#max
|
||||
* @return {number} The largest value from those given.
|
||||
*/
|
||||
max: function () {
|
||||
|
||||
if (arguments.length === 1 && typeof arguments[0] === 'object')
|
||||
{
|
||||
var data = arguments[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = arguments;
|
||||
}
|
||||
|
||||
for (var i = 1, max = 0, len = data.length; i < len; i++)
|
||||
{
|
||||
if (data[i] > data[max])
|
||||
{
|
||||
max = i;
|
||||
}
|
||||
}
|
||||
|
||||
return data[max];
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Updated version of Math.min that can be passed a property and either an array of objects or the objects as parameters.
|
||||
* It will find the lowest matching property value from the given objects.
|
||||
*
|
||||
* @method Phaser.Math#minProperty
|
||||
* @return {number} The lowest value from those given.
|
||||
*/
|
||||
minProperty: function (property) {
|
||||
|
||||
if (arguments.length === 2 && typeof arguments[1] === 'object')
|
||||
{
|
||||
var data = arguments[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = arguments.slice(1);
|
||||
}
|
||||
|
||||
for (var i = 1, min = 0, len = data.length; i < len; i++)
|
||||
{
|
||||
if (data[i][property] < data[min][property])
|
||||
{
|
||||
min = i;
|
||||
}
|
||||
}
|
||||
|
||||
return data[min][property];
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Updated version of Math.max that can be passed a property and either an array of objects or the objects as parameters.
|
||||
* It will find the largest matching property value from the given objects.
|
||||
*
|
||||
* @method Phaser.Math#maxProperty
|
||||
* @return {number} The largest value from those given.
|
||||
*/
|
||||
maxProperty: function (property) {
|
||||
|
||||
if (arguments.length === 2 && typeof arguments[1] === 'object')
|
||||
{
|
||||
var data = arguments[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = arguments.slice(1);
|
||||
}
|
||||
|
||||
for (var i = 1, max = 0, len = data.length; i < len; i++)
|
||||
{
|
||||
if (data[i][property] > data[max][property])
|
||||
{
|
||||
max = i;
|
||||
}
|
||||
}
|
||||
|
||||
return data[max][property];
|
||||
|
||||
},
|
||||
|
||||
@@ -1111,7 +1237,7 @@ Phaser.Math = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* A Linear Interpolation Method, mostly used by Phaser.Tween.
|
||||
* @method Phaser.Math#linearInterpolation
|
||||
* @param {number} v
|
||||
* @param {number} k
|
||||
@@ -1138,7 +1264,7 @@ Phaser.Math = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* A Bezier Interpolation Method, mostly used by Phaser.Tween.
|
||||
* @method Phaser.Math#bezierInterpolation
|
||||
* @param {number} v
|
||||
* @param {number} k
|
||||
@@ -1159,7 +1285,7 @@ Phaser.Math = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Description.
|
||||
* A Catmull Rom Interpolation Method, mostly used by Phaser.Tween.
|
||||
* @method Phaser.Math#catmullRomInterpolation
|
||||
* @param {number} v
|
||||
* @param {number} k
|
||||
@@ -1394,7 +1520,7 @@ Phaser.Math = {
|
||||
* @param {number} y1
|
||||
* @param {number} x2
|
||||
* @param {number} y2
|
||||
* @return {number} The distance between this Point object and the destination Point object.
|
||||
* @return {number} The distance between the two sets of coordinates.
|
||||
*/
|
||||
distance: function (x1, y1, x2, y2) {
|
||||
|
||||
@@ -1405,6 +1531,25 @@ Phaser.Math = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the distance between the two given set of coordinates at the power given.
|
||||
*
|
||||
* @method Phaser.Math#distancePow
|
||||
* @param {number} x1
|
||||
* @param {number} y1
|
||||
* @param {number} x2
|
||||
* @param {number} y2
|
||||
* @param {number} [pow=2]
|
||||
* @return {number} The distance between the two sets of coordinates.
|
||||
*/
|
||||
distancePow: function (x1, y1, x2, y2, pow) {
|
||||
|
||||
if (typeof pow === 'undefined') { pow = 2; }
|
||||
|
||||
return Math.sqrt(Math.pow(x2 - x1, pow) + Math.pow(y2 - y1, pow));
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the rounded distance between the two given set of coordinates.
|
||||
*
|
||||
@@ -1604,13 +1749,13 @@ Phaser.Math = {
|
||||
|
||||
|
||||
<span class="copyright">
|
||||
Phaser Copyright © 2012-2013 Photon Storm Ltd.
|
||||
Phaser Copyright © 2012-2014 Photon Storm Ltd.
|
||||
</span>
|
||||
<br />
|
||||
|
||||
<span class="jsdoc-message">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
|
||||
on Thu Nov 28 2013 15:56:25 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
on Wed Feb 05 2014 06:28:24 GMT-0000 (GMT) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user