mirror of
https://github.com/photonstorm/phaser
synced 2024-11-28 15:41:37 +00:00
Re-format optional parameters.
This commit is contained in:
parent
be8c1618d4
commit
82c5b767c6
20 changed files with 192 additions and 191 deletions
|
@ -108,7 +108,7 @@ module Phaser {
|
|||
* Checks for Line to Line intersection and returns an IntersectResult object containing the results of the intersection.
|
||||
* @param line1 The first Line object to check
|
||||
* @param line2 The second Line object to check
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static lineToLine(line1: Line, line2: Line, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -129,7 +129,7 @@ module Phaser {
|
|||
* Checks for Line to Line Segment intersection and returns an IntersectResult object containing the results of the intersection.
|
||||
* @param line The Line object to check
|
||||
* @param seg The Line segment object to check
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static lineToLineSegment(line: Line, seg: Line, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -164,7 +164,7 @@ module Phaser {
|
|||
* @param y1 The start y coordinate of the raw segment
|
||||
* @param x2 The end x coordinate of the raw segment
|
||||
* @param y2 The end y coordinate of the raw segment
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static lineToRawSegment(line: Line, x1: number, y1: number, x2: number, y2: number, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -196,7 +196,7 @@ module Phaser {
|
|||
* Checks for Line to Ray intersection and returns the result in an IntersectResult object.
|
||||
* @param line1 The Line object to check
|
||||
* @param ray The Ray object to check
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static lineToRay(line1: Line, ray: Line, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -229,7 +229,7 @@ module Phaser {
|
|||
* Check if the Line and Circle objects intersect
|
||||
* @param line The Line object to check
|
||||
* @param circle The Circle object to check
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static lineToCircle(line: Line, circle: Circle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -248,7 +248,7 @@ module Phaser {
|
|||
* Check if the Line intersects each side of the Rectangle
|
||||
* @param line The Line object to check
|
||||
* @param rect The Rectangle object to check
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static lineToRectangle(line: Line, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -288,7 +288,7 @@ module Phaser {
|
|||
* Check if the two Line Segments intersect and returns the result in an IntersectResult object.
|
||||
* @param line1 The first Line Segment to check
|
||||
* @param line2 The second Line Segment to check
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static lineSegmentToLineSegment(line1: Line, line2: Line, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -311,7 +311,7 @@ module Phaser {
|
|||
* Check if the Line Segment intersects with the Ray and returns the result in an IntersectResult object.
|
||||
* @param line The Line Segment to check.
|
||||
* @param ray The Ray to check.
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static lineSegmentToRay(line: Line, ray: Line, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -335,7 +335,7 @@ module Phaser {
|
|||
* Check if the Line Segment intersects with the Circle and returns the result in an IntersectResult object.
|
||||
* @param seg The Line Segment to check.
|
||||
* @param circle The Circle to check
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static lineSegmentToCircle(seg: Line, circle: Circle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -372,7 +372,7 @@ module Phaser {
|
|||
* Check if the Line Segment intersects with the Rectangle and returns the result in an IntersectResult object.
|
||||
* @param seg The Line Segment to check.
|
||||
* @param rect The Rectangle to check.
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static lineSegmentToRectangle(seg: Line, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -422,7 +422,7 @@ module Phaser {
|
|||
* Check for Ray to Rectangle intersection and returns the result in an IntersectResult object.
|
||||
* @param ray The Ray to check.
|
||||
* @param rect The Rectangle to check.
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static rayToRectangle(ray: Line, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -445,7 +445,7 @@ module Phaser {
|
|||
* @param lineY1
|
||||
* @param lineX2
|
||||
* @param lineY2
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static rayToLineSegment(rayX1, rayY1, rayX2, rayY2, lineX1, lineY1, lineX2, lineY2, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -484,7 +484,7 @@ module Phaser {
|
|||
* Determines whether the specified point is contained within the rectangular region defined by the Rectangle object and returns the result in an IntersectResult object.
|
||||
* @param point The Point or MicroPoint object to check, or any object with x and y properties.
|
||||
* @param rect The Rectangle object to check the point against
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static pointToRectangle(point, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -501,7 +501,7 @@ module Phaser {
|
|||
* Check whether two axis aligned Rectangles intersect and returns the intersecting rectangle dimensions in an IntersectResult object if they do.
|
||||
* @param rect1 The first Rectangle object.
|
||||
* @param rect2 The second Rectangle object.
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static rectangleToRectangle(rect1: Rectangle, rect2: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -529,7 +529,7 @@ module Phaser {
|
|||
* Checks if the Rectangle and Circle objects intersect and returns the result in an IntersectResult object.
|
||||
* @param rect The Rectangle object to check
|
||||
* @param circle The Circle object to check
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static rectangleToCircle(rect: Rectangle, circle: Circle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -542,7 +542,7 @@ module Phaser {
|
|||
* Checks if the two Circle objects intersect and returns the result in an IntersectResult object.
|
||||
* @param circle1 The first Circle object to check
|
||||
* @param circle2 The second Circle object to check
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static circleToCircle(circle1: Circle, circle2: Circle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -557,7 +557,7 @@ module Phaser {
|
|||
* Checks if the Circle object intersects with the Rectangle and returns the result in an IntersectResult object.
|
||||
* @param circle The Circle object to check
|
||||
* @param rect The Rectangle object to check
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static circleToRectangle(circle: Circle, rect: Rectangle, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
@ -576,7 +576,7 @@ module Phaser {
|
|||
* Checks if the Point object is contained within the Circle and returns the result in an IntersectResult object.
|
||||
* @param circle The Circle object to check
|
||||
* @param point A Point or MicroPoint object to check, or any object with x and y properties
|
||||
* @param output An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @param [output] An optional IntersectResult object to store the intersection values in. One is created if none given.
|
||||
* @returns {IntersectResult=} An IntersectResult object containing the results of the intersection
|
||||
*/
|
||||
public static circleContainsPoint(circle: Circle, point, output?: IntersectResult = new IntersectResult): IntersectResult {
|
||||
|
|
|
@ -415,8 +415,8 @@ module Phaser {
|
|||
/**
|
||||
* Switch to a new State.
|
||||
* @param state {State} The state you want to switch to.
|
||||
* @param clearWorld {boolean} Optional, clear everything in the world? (Default to true)
|
||||
* @param clearCache {boolean} Optional, clear asset cache? (Default to false and ONLY available when clearWorld=true)
|
||||
* @param [clearWorld] {boolean} clear everything in the world? (Default to true)
|
||||
* @param [clearCache] {boolean} clear asset cache? (Default to false and ONLY available when clearWorld=true)
|
||||
*/
|
||||
public switchState(state, clearWorld: bool = true, clearCache: bool = false) {
|
||||
|
||||
|
@ -655,9 +655,9 @@ module Phaser {
|
|||
* @param key {string} Key for tileset image.
|
||||
* @param mapData {string} Data of this tilemap.
|
||||
* @param format {number} Format of map data. (Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON)
|
||||
* @param resizeWorld {boolean} Optional, resize the world to make same as tilemap?
|
||||
* @param tileWidth {number} Optional, width of each tile.
|
||||
* @param tileHeight {number} Optional, height of each tile.
|
||||
* @param [resizeWorld] {boolean} resize the world to make same as tilemap?
|
||||
* @param [tileWidth] {number} width of each tile.
|
||||
* @param [tileHeight] {number} height of each tile.
|
||||
* @return {Tilemap} The newly created tilemap object.
|
||||
*/
|
||||
public createTilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
|
||||
|
|
|
@ -152,7 +152,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* force a value within the boundaries of two values
|
||||
*
|
||||
*
|
||||
* if max < min, min is returned
|
||||
*/
|
||||
public clamp(input: number, max: number, min: number = 0): number {
|
||||
|
@ -161,12 +161,12 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Snap a value to nearest grid slice, using rounding.
|
||||
*
|
||||
*
|
||||
* example if you have an interval gap of 5 and a position of 12... you will snap to 10. Where as 14 will snap to 15
|
||||
*
|
||||
*
|
||||
* @param input - the value to snap
|
||||
* @param gap - the interval gap of the grid
|
||||
* @param start - optional starting offset for gap
|
||||
* @param [start] - optional starting offset for gap
|
||||
*/
|
||||
public snapTo(input: number, gap: number, start: number = 0): number {
|
||||
if (gap == 0) return input;
|
||||
|
@ -178,12 +178,12 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Snap a value to nearest grid slice, using floor.
|
||||
*
|
||||
*
|
||||
* example if you have an interval gap of 5 and a position of 12... you will snap to 10. As will 14 snap to 10... but 16 will snap to 15
|
||||
*
|
||||
*
|
||||
* @param input - the value to snap
|
||||
* @param gap - the interval gap of the grid
|
||||
* @param start - optional starting offset for gap
|
||||
* @param [start] - optional starting offset for gap
|
||||
*/
|
||||
public snapToFloor(input: number, gap: number, start: number = 0): number {
|
||||
if (gap == 0) return input;
|
||||
|
@ -195,12 +195,12 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Snap a value to nearest grid slice, using ceil.
|
||||
*
|
||||
*
|
||||
* example if you have an interval gap of 5 and a position of 12... you will snap to 15. As will 14 will snap to 15... but 16 will snap to 20
|
||||
*
|
||||
*
|
||||
* @param input - the value to snap
|
||||
* @param gap - the interval gap of the grid
|
||||
* @param start - optional starting offset for gap
|
||||
* @param [start] - optional starting offset for gap
|
||||
*/
|
||||
public snapToCeil(input: number, gap: number, start: number = 0): number {
|
||||
if (gap == 0) return input;
|
||||
|
@ -231,17 +231,17 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* roundTo some place comparative to a 'base', default is 10 for decimal place
|
||||
*
|
||||
*
|
||||
* 'place' is represented by the power applied to 'base' to get that place
|
||||
*
|
||||
*
|
||||
* @param value - the value to round
|
||||
* @param place - the place to round to
|
||||
* @param base - the base to round in... default is 10 for decimal
|
||||
*
|
||||
*
|
||||
* e.g.
|
||||
*
|
||||
*
|
||||
* 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011
|
||||
*
|
||||
*
|
||||
* roundTo(2000/7,3) == 0
|
||||
* roundTo(2000/7,2) == 300
|
||||
* roundTo(2000/7,1) == 290
|
||||
|
@ -251,7 +251,7 @@ module Phaser {
|
|||
* roundTo(2000/7,-3) == 285.714
|
||||
* roundTo(2000/7,-4) == 285.7143
|
||||
* roundTo(2000/7,-5) == 285.71429
|
||||
*
|
||||
*
|
||||
* roundTo(2000/7,3,2) == 288 -- 100100000
|
||||
* roundTo(2000/7,2,2) == 284 -- 100011100
|
||||
* roundTo(2000/7,1,2) == 286 -- 100011110
|
||||
|
@ -261,8 +261,8 @@ module Phaser {
|
|||
* roundTo(2000/7,-3,2) == 285.75 -- 100011101.11
|
||||
* roundTo(2000/7,-4,2) == 285.6875 -- 100011101.1011
|
||||
* roundTo(2000/7,-5,2) == 285.71875 -- 100011101.10111
|
||||
*
|
||||
* note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed
|
||||
*
|
||||
* note what occurs when we round to the 3rd space (8ths place), 100100000, this is to be assumed
|
||||
* because we are rounding 100011.1011011011011011 which rounds up.
|
||||
*/
|
||||
public roundTo(value: number, place: number = 0, base: number = 10): number {
|
||||
|
@ -336,7 +336,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* normalizes independent and then sets dep to the nearest value respective to independent
|
||||
*
|
||||
*
|
||||
* for instance if dep=-170 and ind=170 then 190 will be returned as an alternative to -170
|
||||
*/
|
||||
public normalizeAngleToAnother(dep: number, ind: number, radians: bool = true): number {
|
||||
|
@ -345,7 +345,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* normalize independent and dependent and then set dependent to an angle relative to 'after/clockwise' independent
|
||||
*
|
||||
*
|
||||
* for instance dep=-170 and ind=170, then 190 will be reutrned as alternative to -170
|
||||
*/
|
||||
public normalizeAngleAfterAnother(dep: number, ind: number, radians: bool = true): number {
|
||||
|
@ -356,7 +356,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* normalizes indendent and dependent and then sets dependent to an angle relative to 'before/counterclockwise' independent
|
||||
*
|
||||
*
|
||||
* for instance dep = 190 and ind = 170, then -170 will be returned as an alternative to 190
|
||||
*/
|
||||
public normalizeAngleBeforeAnother(dep: number, ind: number, radians: bool = true): number {
|
||||
|
@ -378,17 +378,17 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Compute the logarithm of any value of any base
|
||||
*
|
||||
* a logarithm is the exponent that some constant (base) would have to be raised to
|
||||
*
|
||||
* a logarithm is the exponent that some constant (base) would have to be raised to
|
||||
* to be equal to value.
|
||||
*
|
||||
*
|
||||
* i.e.
|
||||
* 4 ^ x = 16
|
||||
* can be rewritten as to solve for x
|
||||
* logB4(16) = x
|
||||
* which with this function would be
|
||||
* which with this function would be
|
||||
* LoDMath.logBaseOf(16,4)
|
||||
*
|
||||
*
|
||||
* which would return 2, because 4^2 = 16
|
||||
*/
|
||||
public logBaseOf(value: number, base: number): number {
|
||||
|
@ -434,9 +434,9 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Factorial - N!
|
||||
*
|
||||
*
|
||||
* simple product series
|
||||
*
|
||||
*
|
||||
* by definition:
|
||||
* 0! == 1
|
||||
*/
|
||||
|
@ -455,7 +455,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* gamma function
|
||||
*
|
||||
*
|
||||
* defined: gamma(N) == (N - 1)!
|
||||
*/
|
||||
public gammaFunction(value: number): number {
|
||||
|
@ -464,9 +464,9 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* falling factorial
|
||||
*
|
||||
*
|
||||
* defined: (N)! / (N - x)!
|
||||
*
|
||||
*
|
||||
* written subscript: (N)x OR (base)exp
|
||||
*/
|
||||
public fallingFactorial(base: number, exp: number): number {
|
||||
|
@ -475,9 +475,9 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* rising factorial
|
||||
*
|
||||
*
|
||||
* defined: (N + x - 1)! / (N - 1)!
|
||||
*
|
||||
*
|
||||
* written superscript N^(x) OR base^(exp)
|
||||
*/
|
||||
public risingFactorial(base: number, exp: number): number {
|
||||
|
@ -487,7 +487,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* binomial coefficient
|
||||
*
|
||||
*
|
||||
* defined: N! / (k!(N-k)!)
|
||||
* reduced: N! / (N-k)! == (N)k (fallingfactorial)
|
||||
* reduced: (N)k / k!
|
||||
|
@ -498,10 +498,10 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* rising binomial coefficient
|
||||
*
|
||||
* as one can notice in the analysis of binCoef(...) that
|
||||
* binCoef is the (N)k divided by k!. Similarly rising binCoef
|
||||
* is merely N^(k) / k!
|
||||
*
|
||||
* as one can notice in the analysis of binCoef(...) that
|
||||
* binCoef is the (N)k divided by k!. Similarly rising binCoef
|
||||
* is merely N^(k) / k!
|
||||
*/
|
||||
public risingBinCoef(n: number, k: number): number {
|
||||
return this.risingFactorial(n, k) / this.factorial(k);
|
||||
|
@ -542,7 +542,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Adds the given amount to the value, but never lets the value go over the specified maximum
|
||||
*
|
||||
*
|
||||
* @param value The value to add the amount to
|
||||
* @param amount The amount to add to the value
|
||||
* @param max The maximum the value is allowed to be
|
||||
|
@ -563,7 +563,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Subtracts the given amount from the value, but never lets the value go below the specified minimum
|
||||
*
|
||||
*
|
||||
* @param value The base value
|
||||
* @param amount The amount to subtract from the base value
|
||||
* @param min The minimum the value is allowed to be
|
||||
|
@ -584,7 +584,7 @@ module Phaser {
|
|||
/**
|
||||
* Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.
|
||||
* <p>Values must be positive integers, and are passed through Math.abs</p>
|
||||
*
|
||||
*
|
||||
* @param value The value to add the amount to
|
||||
* @param amount The amount to add to the value
|
||||
* @param max The maximum the value is allowed to be
|
||||
|
@ -606,7 +606,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Randomly returns either a 1 or -1
|
||||
*
|
||||
*
|
||||
* @return 1 or -1
|
||||
*/
|
||||
public randomSign(): number {
|
||||
|
@ -615,9 +615,9 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Returns true if the number given is odd.
|
||||
*
|
||||
*
|
||||
* @param n The number to check
|
||||
*
|
||||
*
|
||||
* @return True if the given number is odd. False if the given number is even.
|
||||
*/
|
||||
public isOdd(n: number): bool {
|
||||
|
@ -635,9 +635,9 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Returns true if the number given is even.
|
||||
*
|
||||
*
|
||||
* @param n The number to check
|
||||
*
|
||||
*
|
||||
* @return True if the given number is even. False if the given number is odd.
|
||||
*/
|
||||
public isEven(n: number): bool {
|
||||
|
@ -656,9 +656,9 @@ module Phaser {
|
|||
/**
|
||||
* Keeps an angle value between -180 and +180<br>
|
||||
* Should be called whenever the angle is updated on the Sprite to stop it from going insane.
|
||||
*
|
||||
*
|
||||
* @param angle The angle value to check
|
||||
*
|
||||
*
|
||||
* @return The new angle value, returns the same as the input angle if it was within bounds
|
||||
*/
|
||||
public wrapAngle(angle: number): number {
|
||||
|
@ -685,11 +685,11 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Keeps an angle value between the given min and max values
|
||||
*
|
||||
*
|
||||
* @param angle The angle value to check. Must be between -180 and +180
|
||||
* @param min The minimum angle that is allowed (must be -180 or greater)
|
||||
* @param max The maximum angle that is allowed (must be 180 or less)
|
||||
*
|
||||
*
|
||||
* @return The new angle value, returns the same as the input angle if it was within bounds
|
||||
*/
|
||||
public angleLimit(angle: number, min: number, max: number): number {
|
||||
|
@ -832,7 +832,7 @@ module Phaser {
|
|||
/**
|
||||
* Generates a random number. Deterministic, meaning safe
|
||||
* to use if you want to record replays in random environments.
|
||||
*
|
||||
*
|
||||
* @return A <code>Number</code> between 0 and 1.
|
||||
*/
|
||||
public random(): number {
|
||||
|
@ -841,9 +841,9 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Generates a random number based on the seed provided.
|
||||
*
|
||||
*
|
||||
* @param Seed A number between 0 and 1, used to generate a predictable random number (very optional).
|
||||
*
|
||||
*
|
||||
* @return A <code>Number</code> between 0 and 1.
|
||||
*/
|
||||
public srand(Seed: number): number {
|
||||
|
@ -855,11 +855,11 @@ module Phaser {
|
|||
/**
|
||||
* Fetch a random entry from the given array.
|
||||
* Will return null if random selection is missing, or array has no entries.
|
||||
*
|
||||
*
|
||||
* @param objects An array of objects.
|
||||
* @param startIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
|
||||
* @param length Optional restriction on the number of values you want to randomly select from.
|
||||
*
|
||||
*
|
||||
* @return The random object that was selected.
|
||||
*/
|
||||
public getRandom(objects, startIndex: number = 0, length: number = 0) {
|
||||
|
@ -885,9 +885,9 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Round down to the next whole number. E.g. floor(1.7) == 1, and floor(-2.7) == -2.
|
||||
*
|
||||
*
|
||||
* @param Value Any number.
|
||||
*
|
||||
*
|
||||
* @return The rounded value of that number.
|
||||
*/
|
||||
public floor(Value: number): number {
|
||||
|
@ -897,9 +897,9 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Round up to the next whole number. E.g. ceil(1.3) == 2, and ceil(-2.3) == -3.
|
||||
*
|
||||
*
|
||||
* @param Value Any number.
|
||||
*
|
||||
*
|
||||
* @return The rounded value of that number.
|
||||
*/
|
||||
public ceil(Value: number): number {
|
||||
|
@ -977,25 +977,25 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Finds the length of the given vector
|
||||
*
|
||||
*
|
||||
* @param dx
|
||||
* @param dy
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public vectorLength(dx:number, dy:number):number
|
||||
{
|
||||
return Math.sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the dot product value of two vectors
|
||||
*
|
||||
*
|
||||
* @param ax Vector X
|
||||
* @param ay Vector Y
|
||||
* @param bx Vector X
|
||||
* @param by Vector Y
|
||||
*
|
||||
*
|
||||
* @return Dot product
|
||||
*/
|
||||
public dotProduct(ax:number, ay:number, bx:number, by:number):number
|
||||
|
|
|
@ -252,25 +252,25 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Recycling is designed to help you reuse game objects without always re-allocating or "newing" them.
|
||||
*
|
||||
*
|
||||
* <p>If you specified a maximum size for this group (like in Emitter),
|
||||
* then recycle will employ what we're calling "rotating" recycling.
|
||||
* Recycle() will first check to see if the group is at capacity yet.
|
||||
* If group is not yet at capacity, recycle() returns a new object.
|
||||
* If the group IS at capacity, then recycle() just returns the next object in line.</p>
|
||||
*
|
||||
*
|
||||
* <p>If you did NOT specify a maximum size for this group,
|
||||
* then recycle() will employ what we're calling "grow-style" recycling.
|
||||
* Recycle() will return either the first object with exists == false,
|
||||
* or, finding none, add a new object to the array,
|
||||
* doubling the size of the array if necessary.</p>
|
||||
*
|
||||
*
|
||||
* <p>WARNING: If this function needs to create a new object,
|
||||
* and no object class was provided, it will return null
|
||||
* instead of a valid object!</p>
|
||||
*
|
||||
*
|
||||
* @param ObjectClass The class type you want to recycle (e.g. Basic, EvilRobot, etc). Do NOT "new" the class in the parameter!
|
||||
*
|
||||
*
|
||||
* @return A reference to the object that was created. Don't forget to cast it back to the Class you want (e.g. myObject = myGroup.recycle(myObjectClass) as myObjectClass;).
|
||||
*/
|
||||
public recycle(ObjectClass = null) {
|
||||
|
@ -320,10 +320,10 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Removes an object from the group.
|
||||
*
|
||||
*
|
||||
* @param object The <code>Basic</code> you want to remove.
|
||||
* @param splice Whether the object should be cut from the array entirely or not.
|
||||
*
|
||||
*
|
||||
* @return The removed object.
|
||||
*/
|
||||
public remove(object: Basic, splice: bool = false): Basic {
|
||||
|
@ -351,10 +351,10 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Replaces an existing <code>Basic</code> with a new one.
|
||||
*
|
||||
*
|
||||
* @param oldObject The object you want to replace.
|
||||
* @param newObject The new object you want to use instead.
|
||||
*
|
||||
*
|
||||
* @return The new object.
|
||||
*/
|
||||
public replace(oldObject: Basic, newObject: Basic): Basic {
|
||||
|
@ -378,9 +378,9 @@ module Phaser {
|
|||
* <code>myGroup.sort("y",Group.ASCENDING)</code> at the bottom of your
|
||||
* <code>State.update()</code> override. To sort all existing objects after
|
||||
* a big explosion or bomb attack, you might call <code>myGroup.sort("exists",Group.DESCENDING)</code>.
|
||||
*
|
||||
*
|
||||
* @param index The <code>string</code> name of the member variable you want to sort on. Default value is "y".
|
||||
* @param order A <code>Group</code> constant that defines the sort order. Possible values are <code>Group.ASCENDING</code> and <code>Group.DESCENDING</code>. Default value is <code>Group.ASCENDING</code>.
|
||||
* @param order A <code>Group</code> constant that defines the sort order. Possible values are <code>Group.ASCENDING</code> and <code>Group.DESCENDING</code>. Default value is <code>Group.ASCENDING</code>.
|
||||
*/
|
||||
public sort(index: string = "y", order: number = Group.ASCENDING) {
|
||||
|
||||
|
@ -392,7 +392,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Go through and set the specified variable to the specified value on all members of the group.
|
||||
*
|
||||
*
|
||||
* @param VariableName The string representation of the variable name you want to modify, for example "visible" or "scrollFactor".
|
||||
* @param Value The value you want to assign to that variable.
|
||||
* @param Recurse Default value is true, meaning if <code>setAll()</code> encounters a member that is a group, it will call <code>setAll()</code> on that group rather than modifying its variable.
|
||||
|
@ -423,7 +423,7 @@ module Phaser {
|
|||
/**
|
||||
* Go through and call the specified function on all members of the group.
|
||||
* Currently only works on functions that have no required parameters.
|
||||
*
|
||||
*
|
||||
* @param FunctionName The string representation of the function you want to call on each object, for example "kill()" or "init()".
|
||||
* @param Recurse Default value is true, meaning if <code>callAll()</code> encounters a member that is a group, it will call <code>callAll()</code> on that group rather than calling the group's function.
|
||||
*/
|
||||
|
@ -501,10 +501,10 @@ module Phaser {
|
|||
/**
|
||||
* Call this function to retrieve the first object with exists == false in the group.
|
||||
* This is handy for recycling in general, e.g. respawning enemies.
|
||||
*
|
||||
* @param ObjectClass An optional parameter that lets you narrow the results to instances of this particular class.
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as not existing.
|
||||
*
|
||||
* @param [ObjectClass] An optional parameter that lets you narrow the results to instances of this particular class.
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as not existing.
|
||||
*/
|
||||
public getFirstAvailable(ObjectClass = null) {
|
||||
|
||||
|
@ -528,7 +528,7 @@ module Phaser {
|
|||
/**
|
||||
* Call this function to retrieve the first index set to 'null'.
|
||||
* Returns -1 if no index stores a null object.
|
||||
*
|
||||
*
|
||||
* @return An <code>int</code> indicating the first null slot in the group.
|
||||
*/
|
||||
public getFirstNull(): number {
|
||||
|
@ -556,7 +556,7 @@ module Phaser {
|
|||
/**
|
||||
* Call this function to retrieve the first object with exists == true in the group.
|
||||
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
|
||||
*
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as existing.
|
||||
*/
|
||||
public getFirstExtant(): Basic {
|
||||
|
@ -581,7 +581,7 @@ module Phaser {
|
|||
/**
|
||||
* Call this function to retrieve the first object with dead == false in the group.
|
||||
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
|
||||
*
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as not dead.
|
||||
*/
|
||||
public getFirstAlive(): Basic {
|
||||
|
@ -606,7 +606,7 @@ module Phaser {
|
|||
/**
|
||||
* Call this function to retrieve the first object with dead == true in the group.
|
||||
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
|
||||
*
|
||||
*
|
||||
* @return A <code>Basic</code> currently flagged as dead.
|
||||
*/
|
||||
public getFirstDead(): Basic {
|
||||
|
@ -630,7 +630,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Call this function to find out how many members of the group are not dead.
|
||||
*
|
||||
*
|
||||
* @return The number of <code>Basic</code>s flagged as not dead. Returns -1 if group is empty.
|
||||
*/
|
||||
public countLiving(): number {
|
||||
|
@ -663,7 +663,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Call this function to find out how many members of the group are dead.
|
||||
*
|
||||
*
|
||||
* @return The number of <code>Basic</code>s flagged as dead. Returns -1 if group is empty.
|
||||
*/
|
||||
public countDead(): number {
|
||||
|
@ -696,10 +696,10 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Returns a member at random from the group.
|
||||
*
|
||||
*
|
||||
* @param StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
|
||||
* @param Length Optional restriction on the number of values you want to randomly select from.
|
||||
*
|
||||
*
|
||||
* @return A <code>Basic</code> from the members list.
|
||||
*/
|
||||
public getRandom(StartIndex: number = 0, Length: number = 0): Basic {
|
||||
|
@ -743,10 +743,10 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Helper function for the sort process.
|
||||
*
|
||||
*
|
||||
* @param Obj1 The first object being sorted.
|
||||
* @param Obj2 The second object being sorted.
|
||||
*
|
||||
*
|
||||
* @return An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2).
|
||||
*/
|
||||
public sortHandler(Obj1: Basic, Obj2: Basic): number {
|
||||
|
|
|
@ -121,8 +121,8 @@ module Phaser {
|
|||
* Add a new texture atlas loading request.
|
||||
* @param key {string} Unique asset key of the texture atlas file.
|
||||
* @param url {string} URL of texture atlas file.
|
||||
* @param jsonURL {string} Optional, url of JSON data file.
|
||||
* @param jsonData {object} Optional, JSON data object.
|
||||
* @param [jsonURL] {string} url of JSON data file.
|
||||
* @param [jsonData] {object} JSON data object.
|
||||
*/
|
||||
public addTextureAtlas(key: string, url: string, jsonURL?: string = null, jsonData? = null) {
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ module Phaser {
|
|||
* Decode a sound with its assets key.
|
||||
* @param key {string} Assets key of the sound to be decoded.
|
||||
* @param callback {function} This will be invoked when finished decoding.
|
||||
* @param sound {Sound} Optional, its bufer will be set to decoded data.
|
||||
* @param [sound] {Sound} its bufer will be set to decoded data.
|
||||
*/
|
||||
public decode(key: string, callback = null, sound?: Sound = null) {
|
||||
|
||||
|
@ -122,8 +122,8 @@ module Phaser {
|
|||
/**
|
||||
* Play a sound with its assets key.
|
||||
* @param key {string} Assets key of the sound you want to play.
|
||||
* @param volume {number} Optional, volume of the sound you want to play.
|
||||
* @param loop {boolean} Optional, loop when it finished playing? (Default to false)
|
||||
* @param [volume] {number} volume of the sound you want to play.
|
||||
* @param [loop] {boolean} loop when it finished playing? (Default to false)
|
||||
* @return {Sound} The playing sound object.
|
||||
*/
|
||||
public play(key: string, volume?: number = 1, loop?: bool = false): Sound {
|
||||
|
|
|
@ -155,7 +155,7 @@ module Phaser {
|
|||
*
|
||||
* @param x {number} X position of the new sprite.
|
||||
* @param y {number} Y position of the new sprite.
|
||||
* @param key {string} Optinal, key for the sprite sheet you want it to use.
|
||||
* @param key {string} [optional] key for the sprite sheet you want it to use.
|
||||
* @returns {Sprite} The newly created sprite object.
|
||||
*/
|
||||
public createSprite(x: number, y: number, key?: string = ''): Sprite {
|
||||
|
@ -176,7 +176,7 @@ module Phaser {
|
|||
/**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param MaxSize {number} Optinal, capacity of this group.
|
||||
* @param MaxSize {number} [optional] capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
public createGroup(MaxSize?: number = 0): Group {
|
||||
|
@ -195,9 +195,9 @@ module Phaser {
|
|||
/**
|
||||
* Create a new Emitter.
|
||||
*
|
||||
* @param x {number} Optinal, x position of the emitter.
|
||||
* @param y {number} Optinal, y position of the emitter.
|
||||
* @param size {number} Optinal, size of this emitter.
|
||||
* @param x {number} [optional] x position of the emitter.
|
||||
* @param y {number} [optional] y position of the emitter.
|
||||
* @param size {number} [optional] size of this emitter.
|
||||
* @return {Emitter} The newly created emitter object.
|
||||
*/
|
||||
public createEmitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
|
||||
|
@ -224,9 +224,9 @@ module Phaser {
|
|||
* @param key {string} Key for tileset image.
|
||||
* @param mapData {string} Data of this tilemap.
|
||||
* @param format {number} Format of map data. (Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON)
|
||||
* @param resizeWorld {boolean} Optinal, resize the world to make same as tilemap?
|
||||
* @param tileWidth {number} Optinal, width of each tile.
|
||||
* @param tileHeight number} Optinal, height of each tile.
|
||||
* @param resizeWorld {boolean} [optional] resize the world to make same as tilemap?
|
||||
* @param tileWidth {number} [optional] width of each tile.
|
||||
* @param tileHeight number} [optional] height of each tile.
|
||||
* @return {Tilemap} The newly created tilemap object.
|
||||
*/
|
||||
public createTilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
|
||||
|
|
|
@ -102,7 +102,7 @@ module Phaser {
|
|||
*
|
||||
* @param width {number} New width of the world.
|
||||
* @param height {number} New height of the world.
|
||||
* @param updateCameraBounds {boolean} Optinal, update camera bounds automatically or not. Default to true.
|
||||
* @param [updateCameraBounds] {boolean} update camera bounds automatically or not. Default to true.
|
||||
*/
|
||||
public setSize(width: number, height: number, updateCameraBounds: bool = true) {
|
||||
|
||||
|
@ -189,7 +189,7 @@ module Phaser {
|
|||
*
|
||||
* @param x {number} X position of the new sprite.
|
||||
* @param y {number} Y position of the new sprite.
|
||||
* @param key {string} Optinal, key for the sprite sheet you want it to use.
|
||||
* @param [key] {string} key for the sprite sheet you want it to use.
|
||||
* @returns {Sprite} The newly created sprite object.
|
||||
*/
|
||||
public createSprite(x: number, y: number, key?: string = ''): Sprite {
|
||||
|
@ -221,7 +221,7 @@ module Phaser {
|
|||
/**
|
||||
* Create a new object container.
|
||||
*
|
||||
* @param MaxSize {number} Optinal, capacity of this group.
|
||||
* @param [MaxSize] {number} capacity of this group.
|
||||
* @returns {Group} The newly created group.
|
||||
*/
|
||||
public createGroup(MaxSize?: number = 0): Group {
|
||||
|
@ -248,9 +248,9 @@ module Phaser {
|
|||
* @param key {string} Key for tileset image.
|
||||
* @param mapData {string} Data of this tilemap.
|
||||
* @param format {number} Format of map data. (Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON)
|
||||
* @param resizeWorld {boolean} Optinal, resize the world to make same as tilemap?
|
||||
* @param tileWidth {number} Optinal, width of each tile.
|
||||
* @param tileHeight {number} Optinal, height of each tile.
|
||||
* @param [resizeWorld] {boolean} resize the world to make same as tilemap?
|
||||
* @param [tileWidth] {number} width of each tile.
|
||||
* @param [tileHeight] {number} height of each tile.
|
||||
* @return {Tilemap} The newly created tilemap object.
|
||||
*/
|
||||
public createTilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
|
||||
|
@ -269,9 +269,9 @@ module Phaser {
|
|||
/**
|
||||
* Create a new Emitter.
|
||||
*
|
||||
* @param x {number} Optinal, x position of the emitter.
|
||||
* @param y {number} Optinal, y position of the emitter.
|
||||
* @param size {number} Optinal, size of this emitter.
|
||||
* @param [x] {number} x position of the emitter.
|
||||
* @param [y] {number} y position of the emitter.
|
||||
* @param [size] {number} size of this emitter.
|
||||
* @return {Emitter} The newly created emitter object.
|
||||
*/
|
||||
public createEmitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
|
||||
|
|
|
@ -19,7 +19,7 @@ module Phaser {
|
|||
*
|
||||
* @param X {number} The X position of the emitter.
|
||||
* @param Y {number} The Y position of the emitter.
|
||||
* @param Size {number} Optional, specifies a maximum capacity for this emitter.
|
||||
* @param [Size] {number} specifies a maximum capacity for this emitter.
|
||||
*/
|
||||
constructor(game: Game, X: number = 0, Y: number = 0, Size: number = 0) {
|
||||
super(game, Size);
|
||||
|
|
|
@ -19,10 +19,10 @@ module Phaser {
|
|||
* Create a new <code>GameObject</code> object at specific position with
|
||||
* specific width and height.
|
||||
*
|
||||
* @param x {number} Optinal, the x position of the object.
|
||||
* @param y {number} Optinal, the y position of the object.
|
||||
* @param width {number} Optinal, the width of the object.
|
||||
* @param height {number} Optinal, the height of the object.
|
||||
* @param [x] {number} The x position of the object.
|
||||
* @param [y] {number} The y position of the object.
|
||||
* @param [width] {number} The width of the object.
|
||||
* @param [height] {number} The height of the object.
|
||||
*/
|
||||
constructor(game: Game, x?: number = 0, y?: number = 0, width?: number = 16, height?: number = 16) {
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ module Phaser {
|
|||
* Create a new <code>GeomSprite</code>.
|
||||
*
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
* @param x {number} Optional, the initial x position of the sprite.
|
||||
* @param y {number} Optional, the initial y position of the sprite.
|
||||
* @param [x] {number} the initial x position of the sprite.
|
||||
* @param [y] {number} the initial y position of the sprite.
|
||||
*/
|
||||
constructor(game: Game, x?: number = 0, y?: number = 0) {
|
||||
|
||||
|
@ -468,7 +468,7 @@ module Phaser {
|
|||
* @param point {Point} Position of the point.
|
||||
* @param offsetX {number} X offset to its position.
|
||||
* @param offsetY {number} Y offset to its position.
|
||||
* @param size {number} Optional, point size.
|
||||
* @param [size] {number} point size.
|
||||
*/
|
||||
public renderPoint(point, offsetX?: number = 0, offsetY?: number = 0, size?: number = 1) {
|
||||
|
||||
|
@ -480,7 +480,7 @@ module Phaser {
|
|||
* Render debug infos. (this method does not work now)
|
||||
* @param x {number} X position of the debug info to be rendered.
|
||||
* @param y {number} Y position of the debug info to be rendered.
|
||||
* @param color {number} Optional, color of the debug info to be rendered. (format is css color string)
|
||||
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
|
||||
*/
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ module Phaser {
|
|||
* @param key {string} Asset key for image texture of this object.
|
||||
* @param x {number} X position in world coordinate.
|
||||
* @param y {number} Y position in world coordinate.
|
||||
* @param width {number} Optional, width of this object.
|
||||
* @param height {number} Optional, height of this object.
|
||||
* @param [width] {number} width of this object.
|
||||
* @param [height] {number} height of this object.
|
||||
*/
|
||||
constructor(game: Game, key:string, x: number = 0, y: number = 0, width?: number = 0, height?: number = 0) {
|
||||
|
||||
|
@ -113,8 +113,8 @@ module Phaser {
|
|||
* @param y {number} Y position of the new region.
|
||||
* @param width {number} Width of the new region.
|
||||
* @param height {number} Height of the new region.
|
||||
* @param speedX {number} Optional, x-axis scrolling speed.
|
||||
* @param speedY {number} Optional, y-axis scrolling speed.
|
||||
* @param [speedX] {number} x-axis scrolling speed.
|
||||
* @param [speedY] {number} y-axis scrolling speed.
|
||||
* @return {ScrollRegion} The newly added region.
|
||||
*/
|
||||
public addRegion(x: number, y: number, width: number, height: number, speedX?:number = 0, speedY?:number = 0):ScrollRegion {
|
||||
|
|
|
@ -19,9 +19,9 @@ module Phaser {
|
|||
* Create a new <code>Sprite</code>.
|
||||
*
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
* @param x {number} Optional, the initial x position of the sprite.
|
||||
* @param y {number} Optional, the initial y position of the sprite.
|
||||
* @param key {string} Optional, Key of the graphic you want to load for this sprite.
|
||||
* @param [x] {number} the initial x position of the sprite.
|
||||
* @param [y] {number} the initial y position of the sprite.
|
||||
* @param [key] {string} Key of the graphic you want to load for this sprite.
|
||||
*/
|
||||
constructor(game: Game, x?: number = 0, y?: number = 0, key?: string = null) {
|
||||
|
||||
|
@ -140,7 +140,7 @@ module Phaser {
|
|||
* This function creates a flat colored square image dynamically.
|
||||
* @param width {number} The width of the sprite you want to generate.
|
||||
* @param height {number} The height of the sprite you want to generate.
|
||||
* @param color {number} Optional, specifies the color of the generated block. (format is 0xAARRGGBB)
|
||||
* @param [color] {number} specifies the color of the generated block. (format is 0xAARRGGBB)
|
||||
* @return {Sprite} Sprite instance itself.
|
||||
*/
|
||||
public makeGraphic(width: number, height: number, color: number = 0xffffffff): Sprite {
|
||||
|
@ -413,7 +413,7 @@ module Phaser {
|
|||
* Render debug infos. (including name, bounds info, position and some other properties)
|
||||
* @param x {number} X position of the debug info to be rendered.
|
||||
* @param y {number} Y position of the debug info to be rendered.
|
||||
* @param color {number} Optional, color of the debug info to be rendered. (format is css color string)
|
||||
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
|
||||
*/
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
|
|
|
@ -315,7 +315,7 @@ module Phaser {
|
|||
* Get the tile located at specific position and layer.
|
||||
* @param x {number} X position of this tile located.
|
||||
* @param y {number} Y position of this tile located.
|
||||
* @param layer {number} Optional, layer of this tile located.
|
||||
* @param [layer] {number} layer of this tile located.
|
||||
* @return {Tile} The tile with specific properties.
|
||||
*/
|
||||
public getTile(x: number, y: number, layer?: number = 0):Tile {
|
||||
|
@ -328,7 +328,7 @@ module Phaser {
|
|||
* Get the tile located at specific position (in world coordinate) and layer. (thus you give a position of a point which is within the tile)
|
||||
* @param x {number} X position of the point in target tile.
|
||||
* @param x {number} Y position of the point in target tile.
|
||||
* @param layer {number} Optional, layer of this tile located.
|
||||
* @param [layer] {number} layer of this tile located.
|
||||
* @return {Tile} The tile with specific properties.
|
||||
*/
|
||||
public getTileFromWorldXY(x: number, y: number, layer?: number = 0):Tile {
|
||||
|
@ -417,7 +417,7 @@ module Phaser {
|
|||
* @param x {number} X position of this tile.
|
||||
* @param y {number} Y position of this tile.
|
||||
* @param index {number} The index of this tile type in the core map data.
|
||||
* @param layer {number} Optional, which layer you want to set the tile to.
|
||||
* @param [layer] {number} which layer you want to set the tile to.
|
||||
*/
|
||||
public putTile(x: number, y: number, index: number, layer?: number = 0) {
|
||||
|
||||
|
|
|
@ -14,8 +14,9 @@ module Phaser {
|
|||
* Creates a new Circle object with the center coordinate specified by the x and y parameters and the diameter specified by the diameter parameter. If you call this function without parameters, a circle with x, y, diameter and radius properties set to 0 is created.
|
||||
* @class Circle
|
||||
* @constructor
|
||||
* @param {Number} x The x coordinate of the center of the circle.
|
||||
* @param {Number} y The y coordinate of the center of the circle.
|
||||
* @param {Number} [x] The x coordinate of the center of the circle.
|
||||
* @param {Number} [y] The y coordinate of the center of the circle.
|
||||
* @param {Number} [diameter] The diameter of the circle.
|
||||
* @return {Circle} This circle object
|
||||
**/
|
||||
constructor(x: number = 0, y: number = 0, diameter: number = 0) {
|
||||
|
@ -27,14 +28,14 @@ module Phaser {
|
|||
private _diameter: number = 0;
|
||||
private _radius: number = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The x coordinate of the center of the circle
|
||||
* @property x
|
||||
* @type Number
|
||||
**/
|
||||
public x: number = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The y coordinate of the center of the circle
|
||||
* @property y
|
||||
* @type Number
|
||||
|
@ -287,7 +288,7 @@ module Phaser {
|
|||
/**
|
||||
* Returns a new Circle object with the same values for the x, y, width, and height properties as the original Circle object.
|
||||
* @method clone
|
||||
* @param {Circle} output Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned.
|
||||
* @param {Circle} [optional] output Optional Circle object. If given the values will be set into the object, otherwise a brand new Circle object will be created and returned.
|
||||
* @return {Phaser.Circle}
|
||||
**/
|
||||
public clone(output?: Circle = new Circle): Circle {
|
||||
|
@ -364,7 +365,7 @@ module Phaser {
|
|||
* Returns the distance from the center of this Circle object to the given object (can be Circle, Point or anything with x/y values)
|
||||
* @method distanceFrom
|
||||
* @param {Circle/Point} target - The destination Point object.
|
||||
* @param {Boolean} round - Round the distance to the nearest integer (default false)
|
||||
* @param {Boolean} [optional] round - Round the distance to the nearest integer (default false)
|
||||
* @return {Number} The distance between this Point object and the destination Point object.
|
||||
**/
|
||||
public distanceTo(target: any, round?: bool = false): number {
|
||||
|
@ -418,9 +419,9 @@ module Phaser {
|
|||
/**
|
||||
* Returns a Point object containing the coordinates of a point on the circumference of this Circle based on the given angle.
|
||||
* @method circumferencePoint
|
||||
* @param {Number} The angle in radians (unless asDegrees is true) to return the point from.
|
||||
* @param {Boolean} Is the given angle in radians (false) or degrees (true)?
|
||||
* @param {Phaser.Point} An optional Point object to put the result in to. If none specified a new Point object will be created.
|
||||
* @param {Number} angle The angle in radians (unless asDegrees is true) to return the point from.
|
||||
* @param {Boolean} asDegrees Is the given angle in radians (false) or degrees (true)?
|
||||
* @param {Phaser.Point} [optional] output An optional Point object to put the result in to. If none specified a new Point object will be created.
|
||||
* @return {Phaser.Point} The Point object holding the result.
|
||||
**/
|
||||
public circumferencePoint(angle: number, asDegrees: bool = false, output?: Point = new Point): Point {
|
||||
|
|
|
@ -196,7 +196,7 @@ module Phaser {
|
|||
/**
|
||||
* Tells this camera object what sprite to track.
|
||||
* @param target {Sprite} The object you want the camera to track. Set to null to not follow anything.
|
||||
* @param style {number} Optional, Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().
|
||||
* @param [style] {number} Leverage one of the existing "deadzone" presets. If you use a custom deadzone, ignore this parameter and manually specify the deadzone after calling follow().
|
||||
*/
|
||||
public follow(target: Sprite, style?: number = Camera.STYLE_LOCKON) {
|
||||
|
||||
|
@ -497,7 +497,7 @@ module Phaser {
|
|||
/**
|
||||
* Set camera background texture.
|
||||
* @param key {string} Asset key of the texture.
|
||||
* @param repeat {string} Optional, what kind of repeat will this texture used for background.
|
||||
* @param [repeat] {string} what kind of repeat will this texture used for background.
|
||||
*/
|
||||
public setTexture(key: string, repeat?: string = 'repeat') {
|
||||
|
||||
|
@ -537,7 +537,7 @@ module Phaser {
|
|||
* Render debug infos. (including id, position, rotation, scrolling factor, bounds and some other properties)
|
||||
* @param x {number} X position of the debug info to be rendered.
|
||||
* @param y {number} Y position of the debug info to be rendered.
|
||||
* @param color {number} Optional, color of the debug info to be rendered. (format is css color string)
|
||||
* @param [color] {number} color of the debug info to be rendered. (format is css color string)
|
||||
*/
|
||||
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ module Phaser {
|
|||
* @param context {object} The AudioContext instance.
|
||||
* @param gainNode {object} Gain node instance.
|
||||
* @param data {object} Sound data.
|
||||
* @param volume {number} Optional, volume of this sound when playing.
|
||||
* @param loop {boolean} Optional, loop this sound when playing? (Default to false)
|
||||
* @param [volume] {number} volume of this sound when playing.
|
||||
* @param [loop] {boolean} loop this sound when playing? (Default to false)
|
||||
*/
|
||||
constructor(context, gainNode, data, volume?: number = 1, loop?: bool = false) {
|
||||
|
||||
|
|
|
@ -189,10 +189,10 @@ module Phaser {
|
|||
* Swap tiles with 2 kinds of indexes.
|
||||
* @param tileA {number} First tile index.
|
||||
* @param tileB {number} Second tile index.
|
||||
* @param x {number} Optional, specify a rectangle of tiles to operate. The x position in tiles of rectangle's left-top corner.
|
||||
* @param y {number} Optional, specify a rectangle of tiles to operate. The y position in tiles of rectangle's left-top corner.
|
||||
* @param width {number} Optional, specify a rectangle of tiles to operate. The width in tiles.
|
||||
* @param height {number} Optional, specify a rectangle of tiles to operate. The height in tiles.
|
||||
* @param [x] {number} specify a rectangle of tiles to operate. The x position in tiles of rectangle's left-top corner.
|
||||
* @param [y] {number} specify a rectangle of tiles to operate. The y position in tiles of rectangle's left-top corner.
|
||||
* @param [width] {number} specify a rectangle of tiles to operate. The width in tiles.
|
||||
* @param [height] {number} specify a rectangle of tiles to operate. The height in tiles.
|
||||
*/
|
||||
public swapTile(tileA: number, tileB: number, x?: number = 0, y?: number = 0, width?: number = this.widthInTiles, height?: number = this.heightInTiles) {
|
||||
|
||||
|
@ -227,10 +227,10 @@ module Phaser {
|
|||
/**
|
||||
* Fill a tile block with a specific tile index.
|
||||
* @param index {number} Index of tiles you want to fill with.
|
||||
* @param x {number} Optional, x position (in tiles) of block's left-top corner.
|
||||
* @param y {number} Optional, y position (in tiles) of block's left-top corner.
|
||||
* @param width {number} Optional, width of block.
|
||||
* @param height {number} Optional, height of block.
|
||||
* @param [x] {number} x position (in tiles) of block's left-top corner.
|
||||
* @param [y] {number} y position (in tiles) of block's left-top corner.
|
||||
* @param [width] {number} width of block.
|
||||
* @param [height] {number} height of block.
|
||||
*/
|
||||
public fillTile(index: number, x?: number = 0, y?: number = 0, width?: number = this.widthInTiles, height?: number = this.heightInTiles) {
|
||||
|
||||
|
@ -246,10 +246,10 @@ module Phaser {
|
|||
/**
|
||||
* Set random tiles to a specific tile block.
|
||||
* @param tiles {number[]} Tiles with indexes in this array will be randomly set to the given block.
|
||||
* @param x {number} Optional, x position (in tiles) of block's left-top corner.
|
||||
* @param y {number} Optional, y position (in tiles) of block's left-top corner.
|
||||
* @param width {number} Optional, width of block.
|
||||
* @param height {number} Optional, height of block.
|
||||
* @param [x] {number} x position (in tiles) of block's left-top corner.
|
||||
* @param [y] {number} y position (in tiles) of block's left-top corner.
|
||||
* @param [width] {number} width of block.
|
||||
* @param [height] {number} height of block.
|
||||
*/
|
||||
public randomiseTiles(tiles: number[], x?: number = 0, y?: number = 0, width?: number = this.widthInTiles, height?: number = this.heightInTiles) {
|
||||
|
||||
|
@ -266,10 +266,10 @@ module Phaser {
|
|||
* Replace one kind of tiles to another kind.
|
||||
* @param tileA {number} Index of tiles you want to replace.
|
||||
* @param tileB {number} Index of tiles you want to set.
|
||||
* @param x {number} Optional, x position (in tiles) of block's left-top corner.
|
||||
* @param y {number} Optional, y position (in tiles) of block's left-top corner.
|
||||
* @param width {number} Optional, width of block.
|
||||
* @param height {number} Optional, height of block.
|
||||
* @param [x] {number} x position (in tiles) of block's left-top corner.
|
||||
* @param [y] {number} y position (in tiles) of block's left-top corner.
|
||||
* @param [width] {number} width of block.
|
||||
* @param [height] {number} height of block.
|
||||
*/
|
||||
public replaceTile(tileA: number, tileB: number, x?: number = 0, y?: number = 0, width?: number = this.widthInTiles, height?: number = this.heightInTiles) {
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ module Phaser {
|
|||
/**
|
||||
* Config the tween result.
|
||||
* @param properties {object} Propertis you want to tween.
|
||||
* @param duration {number} Optional, duration of this tween.
|
||||
* @param [duration] {number} duration of this tween.
|
||||
* @param ease {any} Easing function.
|
||||
* @param autoStart {boolean} Whether this tween will start automatically or not.
|
||||
* @return {Tween} Itself.
|
||||
|
|
|
@ -105,7 +105,7 @@ module Phaser {
|
|||
* Get ranges of frames in an array.
|
||||
* @param start {number} Start index of frames you want.
|
||||
* @param end {number} End index of frames you want.
|
||||
* @param output {Frame[]} Optional, result will be added into this array.
|
||||
* @param [output] {Frame[]} result will be added into this array.
|
||||
* @return {Frame[]} Ranges of specific frames in an array.
|
||||
*/
|
||||
public getFrameRange(start: number, end: number, output?: Frame[] = []): Frame[] {
|
||||
|
@ -121,7 +121,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Get all indexes of frames by giving their name.
|
||||
* @param output {number[]} Optional, result will be added into this array.
|
||||
* @param [output] {number[]} result will be added into this array.
|
||||
* @return {number[]} Indexes of specific frames in an array.
|
||||
*/
|
||||
public getFrameIndexes(output?: number[] = []): number[] {
|
||||
|
@ -139,7 +139,7 @@ module Phaser {
|
|||
|
||||
/**
|
||||
* Get all names of frames by giving their indexes.
|
||||
* @param output {number[]} Optional, result will be added into this array.
|
||||
* @param [output] {number[]} result will be added into this array.
|
||||
* @return {number[]} Names of specific frames in an array.
|
||||
*/
|
||||
public getFrameIndexesByName(input: string[]): number[] {
|
||||
|
|
Loading…
Reference in a new issue