From 1c311a73dfd88b0fb5baddfa4c59ba0e6c69a8a1 Mon Sep 17 00:00:00 2001 From: Sean Date: Sun, 12 May 2013 00:26:30 +0800 Subject: [PATCH] Simply add type info to jsdoc of these classs. --- Phaser/FXManager.ts | 12 ++ Phaser/Group.ts | 71 ++++++----- Phaser/Motion.ts | 208 ++++++++++++++++---------------- Phaser/geom/IntersectResult.ts | 18 +-- Phaser/geom/Line.ts | 50 ++++---- Phaser/geom/MicroPoint.ts | 16 +-- Phaser/geom/Point.ts | 8 +- Phaser/geom/Rectangle.ts | 120 +++++++++--------- Phaser/system/QuadTree.ts | 34 +++--- Phaser/system/input/Finger.ts | 112 ++++++++--------- Phaser/system/input/Input.ts | 55 +++++++++ Phaser/system/input/Keyboard.ts | 26 ++++ Phaser/system/input/Mouse.ts | 24 ++++ Phaser/system/input/Touch.ts | 158 ++++++++++++------------ 14 files changed, 519 insertions(+), 393 deletions(-) diff --git a/Phaser/FXManager.ts b/Phaser/FXManager.ts index af76b90c..70149bcf 100644 --- a/Phaser/FXManager.ts +++ b/Phaser/FXManager.ts @@ -55,6 +55,8 @@ module Phaser { * Adds a new FX to the FXManager. * The effect must be an object with at least one of the following methods: preUpdate, postUpdate, preRender, render or postRender. * A new instance of the effect will be created and a reference to Game will be passed to the object constructor. + * @param {object} effect + * @return {any} */ public add(effect): any { @@ -154,6 +156,11 @@ module Phaser { /** * Pre-render is called at the start of the object render cycle, before any transforms have taken place. * It happens directly AFTER a canvas context.save has happened if added to a Camera. + * @param {Camera} camera + * @param {number} cameraX + * @param {number} cameraY + * @param {number} cameraWidth + * @param {number} cameraHeight */ public preRender(camera:Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) { @@ -172,6 +179,11 @@ module Phaser { /** * render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered. + * @param {Camera} camera + * @param {number} cameraX + * @param {number} cameraY + * @param {number} cameraWidth + * @param {number} cameraHeight */ public render(camera:Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) { diff --git a/Phaser/Group.ts b/Phaser/Group.ts index b30ccf73..25654daa 100644 --- a/Phaser/Group.ts +++ b/Phaser/Group.ts @@ -187,9 +187,9 @@ module Phaser { *

WARNING: If the group has a maxSize that has already been met, * the object will NOT be added to the group!

* - * @param Object The object you want to add to the group. + * @param {Basic} Object The object you want to add to the group. * - * @return The same Basic object that was passed in. + * @return {Basic} The same Basic object that was passed in. */ public add(Object: Basic) { @@ -269,9 +269,9 @@ module Phaser { * and no object class was provided, it will return null * instead of a valid object!

* - * @param ObjectClass The class type you want to recycle (e.g. Basic, EvilRobot, etc). Do NOT "new" the class in the parameter! + * @param {class} 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;). + * @return {any} 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) { @@ -321,10 +321,10 @@ module Phaser { /** * Removes an object from the group. * - * @param object The Basic you want to remove. - * @param splice Whether the object should be cut from the array entirely or not. + * @param {Basic} object The Basic you want to remove. + * @param {boolean} splice Whether the object should be cut from the array entirely or not. * - * @return The removed object. + * @return {Basic} The removed object. */ public remove(object: Basic, splice: bool = false): Basic { @@ -352,10 +352,10 @@ module Phaser { /** * Replaces an existing Basic with a new one. * - * @param oldObject The object you want to replace. - * @param newObject The new object you want to use instead. + * @param {Basic} oldObject The object you want to replace. + * @param {Basic} newObject The new object you want to use instead. * - * @return The new object. + * @return {Basic} The new object. */ public replace(oldObject: Basic, newObject: Basic): Basic { @@ -379,8 +379,8 @@ module Phaser { * State.update() override. To sort all existing objects after * a big explosion or bomb attack, you might call myGroup.sort("exists",Group.DESCENDING). * - * @param index The string name of the member variable you want to sort on. Default value is "y". - * @param order A Group constant that defines the sort order. Possible values are Group.ASCENDING and Group.DESCENDING. Default value is Group.ASCENDING. + * @param {string} index The string name of the member variable you want to sort on. Default value is "y". + * @param {number} order A Group constant that defines the sort order. Possible values are Group.ASCENDING and Group.DESCENDING. Default value is Group.ASCENDING. */ public sort(index: string = "y", order: number = Group.ASCENDING) { @@ -393,9 +393,9 @@ 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 setAll() encounters a member that is a group, it will call setAll() on that group rather than modifying its variable. + * @param {string} VariableName The string representation of the variable name you want to modify, for example "visible" or "scrollFactor". + * @param {Object} Value The value you want to assign to that variable. + * @param {boolean} Recurse Default value is true, meaning if setAll() encounters a member that is a group, it will call setAll() on that group rather than modifying its variable. */ public setAll(VariableName: string, Value: Object, Recurse: bool = true) { @@ -424,8 +424,8 @@ 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 callAll() encounters a member that is a group, it will call callAll() on that group rather than calling the group's function. + * @param {string} FunctionName The string representation of the function you want to call on each object, for example "kill()" or "init()". + * @param {boolean} Recurse Default value is true, meaning if callAll() encounters a member that is a group, it will call callAll() on that group rather than calling the group's function. */ public callAll(FunctionName: string, Recurse: bool = true) { @@ -450,6 +450,10 @@ module Phaser { } } + /** + * @param {function} callback + * @param {boolean} recursive + */ public forEach(callback, recursive: bool = false) { var basic; @@ -474,6 +478,11 @@ module Phaser { } + /** + * @param {any} context + * @param {function} callback + * @param {boolean} recursive + */ public forEachAlive(context, callback, recursive: bool = false) { var basic; @@ -502,9 +511,9 @@ 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. + * @param {any} [ObjectClass] An optional parameter that lets you narrow the results to instances of this particular class. * - * @return A Basic currently flagged as not existing. + * @return {any} A Basic currently flagged as not existing. */ public getFirstAvailable(ObjectClass = null) { @@ -529,7 +538,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 int indicating the first null slot in the group. + * @return {number} An int indicating the first null slot in the group. */ public getFirstNull(): number { @@ -557,7 +566,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 Basic currently flagged as existing. + * @return {Basic} A Basic currently flagged as existing. */ public getFirstExtant(): Basic { @@ -582,7 +591,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 Basic currently flagged as not dead. + * @return {Basic} A Basic currently flagged as not dead. */ public getFirstAlive(): Basic { @@ -607,7 +616,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 Basic currently flagged as dead. + * @return {Basic} A Basic currently flagged as dead. */ public getFirstDead(): Basic { @@ -631,7 +640,7 @@ module Phaser { /** * Call this function to find out how many members of the group are not dead. * - * @return The number of Basics flagged as not dead. Returns -1 if group is empty. + * @return {number} The number of Basics flagged as not dead. Returns -1 if group is empty. */ public countLiving(): number { @@ -664,7 +673,7 @@ module Phaser { /** * Call this function to find out how many members of the group are dead. * - * @return The number of Basics flagged as dead. Returns -1 if group is empty. + * @return {number} The number of Basics flagged as dead. Returns -1 if group is empty. */ public countDead(): number { @@ -697,10 +706,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. + * @param {number} StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array. + * @param {number} Length Optional restriction on the number of values you want to randomly select from. * - * @return A Basic from the members list. + * @return {Basic} A Basic from the members list. */ public getRandom(StartIndex: number = 0, Length: number = 0): Basic { @@ -744,10 +753,10 @@ module Phaser { /** * Helper function for the sort process. * - * @param Obj1 The first object being sorted. - * @param Obj2 The second object being sorted. + * @param {Basic} Obj1 The first object being sorted. + * @param {Basic} Obj2 The second object being sorted. * - * @return An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2). + * @return {number} An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2). */ public sortHandler(Obj1: Basic, Obj2: Basic): number { diff --git a/Phaser/Motion.ts b/Phaser/Motion.ts index 0dfb4630..6d91c688 100644 --- a/Phaser/Motion.ts +++ b/Phaser/Motion.ts @@ -21,13 +21,13 @@ module Phaser { /** * A tween-like function that takes a starting velocity and some other factors and returns an altered velocity. - * - * @param Velocity Any component of velocity (e.g. 20). - * @param Acceleration Rate at which the velocity is changing. - * @param Drag Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set. - * @param Max An absolute value cap for the velocity. - * - * @return The altered Velocity value. + * + * @param {number} Velocity Any component of velocity (e.g. 20). + * @param {number} Acceleration Rate at which the velocity is changing. + * @param {number} Drag Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set. + * @param {number} Max An absolute value cap for the velocity. + * + * @return {number} The altered Velocity value. */ public computeVelocity(Velocity: number, Acceleration: number = 0, Drag: number = 0, Max: number = 10000): number { @@ -71,11 +71,11 @@ module Phaser { /** * Given the angle and speed calculate the velocity and return it as a Point - * - * @param angle The angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * @param speed The speed it will move, in pixels per second sq - * - * @return A Point where Point.x contains the velocity x value and Point.y contains the velocity y value + * + * @param {number} angle The angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) + * @param {number} speed The speed it will move, in pixels per second sq + * + * @return {Point} A Point where Point.x contains the velocity x value and Point.y contains the velocity y value */ public velocityFromAngle(angle: number, speed: number): Point { @@ -97,24 +97,24 @@ module Phaser { * The source object doesn't stop moving automatically should it ever reach the destination coordinates.
* If you need the object to accelerate, see accelerateTowardsObject() instead * Note: Doesn't take into account acceleration, maxVelocity or drag (if you set drag or acceleration too high this object may not move at all) - * - * @param source The Sprite on which the velocity will be set - * @param dest The Sprite where the source object will move to - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms + * + * @param {GameObject} source The Sprite on which the velocity will be set + * @param {GameObject} dest The Sprite where the source object will move to + * @param {number} speed The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms */ public moveTowardsObject(source:GameObject, dest:GameObject, speed:number= 60, maxTime:number = 0) { var a:number = this.angleBetween(source, dest); - + if (maxTime > 0) { var d:number = this.distanceBetween(source, dest); - + // We know how many pixels we need to move, but how fast? speed = d / (maxTime / 1000); } - + source.velocity.x = Math.cos(a) * speed; source.velocity.y = Math.sin(a) * speed; @@ -124,23 +124,23 @@ module Phaser { * Sets the x/y acceleration on the source Sprite so it will move towards the destination Sprite at the speed given (in pixels per second)
* You must give a maximum speed value, beyond which the Sprite won't go any faster.
* If you don't need acceleration look at moveTowardsObject() instead. - * - * @param source The Sprite on which the acceleration will be set - * @param dest The Sprite where the source object will move towards - * @param speed The speed it will accelerate in pixels per second - * @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally - * @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically + * + * @param {GameObject} source The Sprite on which the acceleration will be set + * @param {GameObject} dest The Sprite where the source object will move towards + * @param {number} speed The speed it will accelerate in pixels per second + * @param {number} xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally + * @param {number} ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically */ public accelerateTowardsObject(source:GameObject, dest:GameObject, speed:number, xSpeedMax:number, ySpeedMax:number) { var a:number = this.angleBetween(source, dest); - + source.velocity.x = 0; source.velocity.y = 0; - + source.acceleration.x = Math.cos(a) * speed; source.acceleration.y = Math.sin(a) * speed; - + source.maxVelocity.x = xSpeedMax; source.maxVelocity.y = ySpeedMax; @@ -151,23 +151,23 @@ module Phaser { * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
* Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.
* The source object doesn't stop moving automatically should it ever reach the destination coordinates.
- * - * @param source The Sprite to move - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms + * + * @param {GameObject} source The Sprite to move + * @param {number} speed The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms */ public moveTowardsMouse(source:GameObject, speed:number = 60, maxTime:number = 0) { var a:number = this.angleBetweenMouse(source); - + if (maxTime > 0) { var d:number = this.distanceToMouse(source); - + // We know how many pixels we need to move, but how fast? speed = d / (maxTime / 1000); } - + source.velocity.x = Math.cos(a) * speed; source.velocity.y = Math.sin(a) * speed; @@ -177,22 +177,22 @@ module Phaser { * Sets the x/y acceleration on the source Sprite so it will move towards the mouse coordinates at the speed given (in pixels per second)
* You must give a maximum speed value, beyond which the Sprite won't go any faster.
* If you don't need acceleration look at moveTowardsMouse() instead. - * - * @param source The Sprite on which the acceleration will be set - * @param speed The speed it will accelerate in pixels per second - * @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally - * @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically + * + * @param {GameObject} source The Sprite on which the acceleration will be set + * @param {number} speed The speed it will accelerate in pixels per second + * @param {number} xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally + * @param {number} ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically */ public accelerateTowardsMouse(source:GameObject, speed:number, xSpeedMax:number, ySpeedMax:number) { var a:number = this.angleBetweenMouse(source); - + source.velocity.x = 0; source.velocity.y = 0; - + source.acceleration.x = Math.cos(a) * speed; source.acceleration.y = Math.sin(a) * speed; - + source.maxVelocity.x = xSpeedMax; source.maxVelocity.y = ySpeedMax; } @@ -202,24 +202,24 @@ module Phaser { * If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
* Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.
* The source object doesn't stop moving automatically should it ever reach the destination coordinates.
- * - * @param source The Sprite to move - * @param target The Point coordinates to move the source Sprite towards - * @param speed The speed it will move, in pixels per second (default is 60 pixels/sec) - * @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms + * + * @param {GameObject} source The Sprite to move + * @param {Point} target The Point coordinates to move the source Sprite towards + * @param {number} speed The speed it will move, in pixels per second (default is 60 pixels/sec) + * @param {number} maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms */ public moveTowardsPoint(source:GameObject, target:Point, speed:number = 60, maxTime:number = 0) { var a:number = this.angleBetweenPoint(source, target); - + if (maxTime > 0) { var d:number = this.distanceToPoint(source, target); - + // We know how many pixels we need to move, but how fast? speed = d / (maxTime / 1000); } - + source.velocity.x = Math.cos(a) * speed; source.velocity.y = Math.sin(a) * speed; } @@ -228,87 +228,87 @@ module Phaser { * Sets the x/y acceleration on the source Sprite so it will move towards the target coordinates at the speed given (in pixels per second)
* You must give a maximum speed value, beyond which the Sprite won't go any faster.
* If you don't need acceleration look at moveTowardsPoint() instead. - * - * @param source The Sprite on which the acceleration will be set - * @param target The Point coordinates to move the source Sprite towards - * @param speed The speed it will accelerate in pixels per second - * @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally - * @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically + * + * @param {GameObject} source The Sprite on which the acceleration will be set + * @param {Point} target The Point coordinates to move the source Sprite towards + * @param {number} speed The speed it will accelerate in pixels per second + * @param {number} xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally + * @param {number} ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically */ public accelerateTowardsPoint(source:GameObject, target:Point, speed:number, xSpeedMax:number, ySpeedMax:number) { var a:number = this.angleBetweenPoint(source, target); - + source.velocity.x = 0; source.velocity.y = 0; - + source.acceleration.x = Math.cos(a) * speed; source.acceleration.y = Math.sin(a) * speed; - + source.maxVelocity.x = xSpeedMax; source.maxVelocity.y = ySpeedMax; } /** * Find the distance (in pixels, rounded) between two Sprites, taking their origin into account - * - * @param a The first Sprite - * @param b The second Sprite - * @return int Distance (in pixels) + * + * @param {GameObject} a The first Sprite + * @param {GameObject} b The second Sprite + * @return {number} int Distance (in pixels) */ public distanceBetween(a:GameObject, b:GameObject):number { var dx:number = (a.x + a.origin.x) - (b.x + b.origin.x); var dy:number = (a.y + a.origin.y) - (b.y + b.origin.y); - + return this._game.math.vectorLength(dx, dy); } /** * Find the distance (in pixels, rounded) from an Sprite to the given Point, taking the source origin into account - * - * @param a The Sprite - * @param target The Point - * @return int Distance (in pixels) + * + * @param {GameObject} a The Sprite + * @param {Point} target The Point + * @return {number} Distance (in pixels) */ public distanceToPoint(a:GameObject, target:Point):number { var dx:number = (a.x + a.origin.x) - (target.x); var dy:number = (a.y + a.origin.y) - (target.y); - + return this._game.math.vectorLength(dx, dy); } /** * Find the distance (in pixels, rounded) from the object x/y and the mouse x/y - * - * @param a The Sprite to test against - * @return int The distance between the given sprite and the mouse coordinates + * + * @param {GameObject} a Sprite to test against + * @return {number} The distance between the given sprite and the mouse coordinates */ public distanceToMouse(a:GameObject):number { var dx: number = (a.x + a.origin.x) - this._game.input.x; var dy: number = (a.y + a.origin.y) - this._game.input.y; - + return this._game.math.vectorLength(dx, dy); } /** * Find the angle (in radians) between an Sprite and an Point. The source sprite takes its x/y and origin into account. * The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * - * @param a The Sprite to test from - * @param target The Point to angle the Sprite towards - * @param asDegrees If you need the value in degrees instead of radians, set to true - * - * @return Number The angle (in radians unless asDegrees is true) + * + * @param {GameObject} a The Sprite to test from + * @param {Point} target The Point to angle the Sprite towards + * @param {boolean} asDegrees If you need the value in degrees instead of radians, set to true + * + * @return {number} The angle (in radians unless asDegrees is true) */ public angleBetweenPoint(a:GameObject, target:Point, asDegrees:bool = false):number { var dx:number = (target.x) - (a.x + a.origin.x); var dy:number = (target.y) - (a.y + a.origin.y); - + if (asDegrees) { return this._game.math.radiansToDegrees(Math.atan2(dy, dx)); @@ -322,18 +322,18 @@ module Phaser { /** * Find the angle (in radians) between the two Sprite, taking their x/y and origin into account. * The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * - * @param a The Sprite to test from - * @param b The Sprite to test to - * @param asDegrees If you need the value in degrees instead of radians, set to true - * - * @return Number The angle (in radians unless asDegrees is true) + * + * @param {GameObject} a The Sprite to test from + * @param {GameObject} b The Sprite to test to + * @param {boolean} asDegrees If you need the value in degrees instead of radians, set to true + * + * @return {number} The angle (in radians unless asDegrees is true) */ public angleBetween(a:GameObject, b:GameObject, asDegrees:bool = false):number { var dx:number = (b.x + b.origin.x) - (a.x + a.origin.x); var dy:number = (b.y + b.origin.y) - (a.y + a.origin.y); - + if (asDegrees) { return this._game.math.radiansToDegrees(Math.atan2(dy, dx)); @@ -346,16 +346,16 @@ module Phaser { /** * Given the GameObject and speed calculate the velocity and return it as an Point based on the direction the sprite is facing - * - * @param parent The Sprite to get the facing value from - * @param speed The speed it will move, in pixels per second sq - * - * @return An Point where Point.x contains the velocity x value and Point.y contains the velocity y value + * + * @param {GameObject} parent The Sprite to get the facing value from + * @param {number} speed The speed it will move, in pixels per second sq + * + * @return {Point} An Point where Point.x contains the velocity x value and Point.y contains the velocity y value */ public velocityFromFacing(parent:GameObject, speed:number):Point { var a:number; - + if (parent.facing == Collision.LEFT) { a = this._game.math.degreesToRadians(180); @@ -372,28 +372,28 @@ module Phaser { { a = this._game.math.degreesToRadians(90); } - + return new Point(Math.cos(a) * speed, Math.sin(a) * speed); } - + /** * Find the angle (in radians) between an Sprite and the mouse, taking their x/y and origin into account. * The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) - * - * @param a The Object to test from - * @param asDegrees If you need the value in degrees instead of radians, set to true - * - * @return Number The angle (in radians unless asDegrees is true) + * + * @param {GameObject} a The Object to test from + * @param {boolean} asDegrees If you need the value in degrees instead of radians, set to true + * + * @return {number} The angle (in radians unless asDegrees is true) */ public angleBetweenMouse(a:GameObject, asDegrees:bool = false):number { // In order to get the angle between the object and mouse, we need the objects screen coordinates (rather than world coordinates) var p:MicroPoint = a.getScreenXY(); - + var dx:number = a._game.input.x - p.x; var dy:number = a._game.input.y - p.y; - + if (asDegrees) { return this._game.math.radiansToDegrees(Math.atan2(dy, dx)); diff --git a/Phaser/geom/IntersectResult.ts b/Phaser/geom/IntersectResult.ts index 8ceb6fce..6555b198 100644 --- a/Phaser/geom/IntersectResult.ts +++ b/Phaser/geom/IntersectResult.ts @@ -13,55 +13,55 @@ module Phaser { /** * Did they intersect or not? * @property result - * @type Boolean + * @type {Boolean} */ result: bool = false; /** * @property x - * @type Number + * @type {Number} */ x: number; /** * @property y - * @type Number + * @type {Number} */ y: number; /** * @property x1 - * @type Number + * @type {Number} */ x1: number; /** * @property y1 - * @type Number + * @type {Number} */ y1: number; /** * @property x2 - * @type Number + * @type {Number} */ x2: number; /** * @property y2 - * @type Number + * @type {Number} */ y2: number; /** * @property width - * @type Number + * @type {Number} */ width: number; /** * @property height - * @type Number + * @type {Number} */ height: number; diff --git a/Phaser/geom/Line.ts b/Phaser/geom/Line.ts index 64c5f08b..18aefa30 100644 --- a/Phaser/geom/Line.ts +++ b/Phaser/geom/Line.ts @@ -11,7 +11,7 @@ module Phaser { export class Line { /** - * + * * @constructor * @param {Number} x1 * @param {Number} y1 @@ -26,35 +26,35 @@ module Phaser { } /** - * + * * @property x1 - * @type Number + * @type {Number} */ public x1: number = 0; /** - * + * * @property y1 - * @type Number + * @type {Number} */ public y1: number = 0; /** - * + * * @property x2 - * @type Number + * @type {Number} */ public x2: number = 0; /** - * + * * @property y2 - * @type Number + * @type {Number} */ public y2: number = 0; /** - * + * * @method clone * @param {Phaser.Line} [output] * @return {Phaser.Line} @@ -66,7 +66,7 @@ module Phaser { } /** - * + * * @method copyFrom * @param {Phaser.Line} source * @return {Phaser.Line} @@ -78,7 +78,7 @@ module Phaser { } /** - * + * * @method copyTo * @param {Phaser.Line} target * @return {Phaser.Line} @@ -90,7 +90,7 @@ module Phaser { } /** - * + * * @method setTo * @param {Number} x1 * @param {Number} y1 @@ -122,7 +122,7 @@ module Phaser { } /** - * + * * @method length * @return {Number} */ @@ -133,7 +133,7 @@ module Phaser { } /** - * + * * @method getY * @param {Number} x * @return {Number} @@ -145,7 +145,7 @@ module Phaser { } /** - * + * * @method angle * @return {Number} */ @@ -156,7 +156,7 @@ module Phaser { } /** - * + * * @method slope * @return {Number} */ @@ -167,7 +167,7 @@ module Phaser { } /** - * + * * @method perpSlope * @return {Number} */ @@ -178,7 +178,7 @@ module Phaser { } /** - * + * * @method yIntercept * @return {Number} */ @@ -189,7 +189,7 @@ module Phaser { } /** - * + * * @method isPointOnLine * @param {Number} x * @param {Number} y @@ -209,7 +209,7 @@ module Phaser { } /** - * + * * @method isPointOnLineSegment * @param {Number} x * @param {Number} y @@ -234,7 +234,7 @@ module Phaser { } /** - * + * * @method intersectLineLine * @param {Any} line * @return {Any} @@ -244,7 +244,7 @@ module Phaser { } /** - * + * * @method perp * @param {Number} x * @param {Number} y @@ -285,12 +285,12 @@ module Phaser { { var perp = this.perp() return Phaser.intersectLineCircle(this,circle); - + } */ /** - * + * * @method toString * @return {String} */ diff --git a/Phaser/geom/MicroPoint.ts b/Phaser/geom/MicroPoint.ts index 10cf8231..921e6172 100644 --- a/Phaser/geom/MicroPoint.ts +++ b/Phaser/geom/MicroPoint.ts @@ -33,10 +33,10 @@ module Phaser { public parent: any; - /** + /** * The x coordinate of the top-left corner of the rectangle * @property x - * @type Number + * @type {Number} **/ public get x(): number { @@ -44,10 +44,10 @@ module Phaser { } - /** + /** * The y coordinate of the top-left corner of the rectangle * @property y - * @type Number + * @type {Number} **/ public get y(): number { @@ -55,10 +55,10 @@ module Phaser { } - /** + /** * The x coordinate of the top-left corner of the rectangle * @property x - * @type Number + * @type {Number} **/ public set x(value: number) { @@ -71,10 +71,10 @@ module Phaser { } - /** + /** * The y coordinate of the top-left corner of the rectangle * @property y - * @type Number + * @type {Number} **/ public set y(value:number) { diff --git a/Phaser/geom/Point.ts b/Phaser/geom/Point.ts index 932013ab..e697b369 100644 --- a/Phaser/geom/Point.ts +++ b/Phaser/geom/Point.ts @@ -23,17 +23,17 @@ module Phaser { } - /** + /** * The horizontal position of this point (default 0) * @property x - * @type Number + * @type {Number} **/ public x: number; - /** + /** * The vertical position of this point (default 0) * @property y - * @type Number + * @type {Number} **/ public y: number; diff --git a/Phaser/geom/Rectangle.ts b/Phaser/geom/Rectangle.ts index dc51dd0a..77843319 100644 --- a/Phaser/geom/Rectangle.ts +++ b/Phaser/geom/Rectangle.ts @@ -57,10 +57,10 @@ module Phaser { private _tempWidth: number = null; private _tempHeight: number = null; - /** + /** * The x coordinate of the top-left corner of the rectangle * @property x - * @type Number + * @type {Number} **/ public get x(): number { @@ -68,10 +68,10 @@ module Phaser { } - /** + /** * The y coordinate of the top-left corner of the rectangle * @property y - * @type Number + * @type {Number} **/ public get y(): number { @@ -79,10 +79,10 @@ module Phaser { } - /** + /** * The x coordinate of the top-left corner of the rectangle * @property x - * @type Number + * @type {Number} **/ public set x(value: number) { @@ -90,10 +90,10 @@ module Phaser { } - /** + /** * The y coordinate of the top-left corner of the rectangle * @property y - * @type Number + * @type {Number} **/ public set y(value:number) { @@ -101,105 +101,105 @@ module Phaser { } - /** + /** * The x and y coordinate of the top-left corner of the rectangle (same as x/y) * @property topLeft - * @type MicroPoint + * @type {MicroPoint} **/ public topLeft: MicroPoint; - /** + /** * The x and y coordinate of the top-center of the rectangle * @property topCenter - * @type MicroPoint + * @type {MicroPoint} **/ public topCenter: MicroPoint; - /** + /** * The x and y coordinate of the top-right corner of the rectangle * @property topRight - * @type MicroPoint + * @type {MicroPoint} **/ public topRight: MicroPoint; - /** + /** * The x and y coordinate of the left-center of the rectangle * @property leftCenter - * @type MicroPoint + * @type {MicroPoint} **/ public leftCenter: MicroPoint; - /** + /** * The x and y coordinate of the center of the rectangle * @property center - * @type MicroPoint + * @type {MicroPoint} **/ public center: MicroPoint; - /** + /** * The x and y coordinate of the right-center of the rectangle * @property rightCenter - * @type MicroPoint + * @type {MicroPoint} **/ public rightCenter: MicroPoint; - /** + /** * The x and y coordinate of the bottom-left corner of the rectangle * @property bottomLeft - * @type MicroPoint + * @type {MicroPoint} **/ public bottomLeft: MicroPoint; - /** + /** * The x and y coordinate of the bottom-center of the rectangle * @property bottomCenter - * @type MicroPoint + * @type {MicroPoint} **/ public bottomCenter: MicroPoint; - /** + /** * The x and y coordinate of the bottom-right corner of the rectangle * @property bottomRight - * @type MicroPoint + * @type {MicroPoint} **/ public bottomRight: MicroPoint; - /** + /** * The width of the rectangle * @property width - * @type Number + * @type {Number} **/ private _width: number = 0; - /** + /** * The height of the rectangle * @property height - * @type Number + * @type {Number} **/ private _height: number = 0; - /** + /** * Half of the width of the rectangle * @property halfWidth - * @type Number + * @type {Number} **/ private _halfWidth: number = 0; - /** + /** * Half of the height of the rectangle * @property halfHeight - * @type Number + * @type {Number} **/ private _halfHeight: number = 0; - /** + /** * The size of the longest side (width or height) * @property length - * @type Number + * @type {Number} **/ public length: number = 0; - /** + /** * Updates all of the MicroPoints based on the values of width and height. * You should not normally call this directly. **/ @@ -264,10 +264,10 @@ module Phaser { } - /** + /** * The width of the rectangle * @property width - * @type Number + * @type {Number} **/ public set width(value: number) { @@ -277,10 +277,10 @@ module Phaser { } - /** + /** * The height of the rectangle * @property height - * @type Number + * @type {Number} **/ public set height(value: number) { @@ -290,10 +290,10 @@ module Phaser { } - /** + /** * The width of the rectangle * @property width - * @type Number + * @type {Number} **/ public get width(): number { @@ -301,10 +301,10 @@ module Phaser { } - /** + /** * The height of the rectangle * @property height - * @type Number + * @type {Number} **/ public get height(): number { @@ -312,10 +312,10 @@ module Phaser { } - /** + /** * Half of the width of the rectangle * @property halfWidth - * @type Number + * @type {Number} **/ public get halfWidth(): number { @@ -323,10 +323,10 @@ module Phaser { } - /** + /** * Half of the height of the rectangle * @property halfHeight - * @type Number + * @type {Number} **/ public get halfHeight(): number { @@ -350,7 +350,7 @@ module Phaser { * The sum of the y and height properties. * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. * @method bottom - * @param {Number} value + * @param {Number} value **/ public set bottom(value: number) { @@ -372,7 +372,7 @@ module Phaser { * Changing the left property of a Rectangle object has no effect on the y and height properties. * However it does affect the width property, whereas changing the x value does not affect the width property. * @method left - * @ return {number} + * @ return {Number} **/ public get left(): number { @@ -385,7 +385,7 @@ module Phaser { * Changing the left property of a Rectangle object has no effect on the y and height properties. * However it does affect the width property, whereas changing the x value does not affect the width property. * @method left - * @param {Number} value + * @param {Number} value **/ public set left(value: number) { @@ -411,7 +411,7 @@ module Phaser { * Changing the right property of a Rectangle object has no effect on the x, y and height properties. * However it does affect the width property. * @method right - * @return {Number} + * @return {Number} **/ public get right(): number { @@ -424,7 +424,7 @@ module Phaser { * Changing the right property of a Rectangle object has no effect on the x, y and height properties. * However it does affect the width property. * @method right - * @param {Number} value + * @param {Number} value **/ public set right(value: number) { @@ -456,7 +456,7 @@ module Phaser { /** * The volume of the Rectangle object in pixels, derived from width * height * @method volume - * @return {Number} + * @return {Number} **/ public get volume(): number { @@ -467,7 +467,7 @@ module Phaser { /** * The perimeter size of the Rectangle object in pixels. This is the sum of all 4 sides. * @method perimeter - * @return {Number} + * @return {Number} **/ public get perimeter(): number { @@ -480,7 +480,7 @@ module Phaser { * Changing the top property of a Rectangle object has no effect on the x and width properties. * However it does affect the height property, whereas changing the y value does not affect the height property. * @method top - * @return {Number} + * @return {Number} **/ public get top(): number { @@ -626,7 +626,7 @@ module Phaser { /** * Increases the size of the Rectangle object by the specified amounts. - * The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, + * The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value, * and to the top and the bottom by the dy value. * @method inflate * @param {Number} dx The amount to be added to the left side of this Rectangle. @@ -661,7 +661,7 @@ module Phaser { /** * If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object, - * returns the area of intersection as a Rectangle object. If the rectangles do not intersect, this method + * returns the area of intersection as a Rectangle object. If the rectangles do not intersect, this method * returns an empty Rectangle object with its properties set to 0. * @method intersection * @param {Rectangle} toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object. @@ -797,7 +797,7 @@ module Phaser { /** * Returns a string representation of this object. * @method toString - * @return {string} a string representation of the instance. + * @return {String} a string representation of the instance. **/ public toString(): string { diff --git a/Phaser/system/QuadTree.ts b/Phaser/system/QuadTree.ts index 0e799c58..046830f0 100644 --- a/Phaser/system/QuadTree.ts +++ b/Phaser/system/QuadTree.ts @@ -15,12 +15,12 @@ module Phaser { /** * Instantiate a new Quad Tree node. - * - * @param X The X-coordinate of the point in space. - * @param Y The Y-coordinate of the point in space. - * @param Width Desired width of this node. - * @param Height Desired height of this node. - * @param Parent The parent branch or node. Pass null to create a root. + * + * @param {Number} X The X-coordinate of the point in space. + * @param {Number} Y The Y-coordinate of the point in space. + * @param {Number} Width Desired width of this node. + * @param {Number} Height Desired height of this node. + * @param {Number} Parent The parent branch or node. Pass null to create a root. */ constructor(X: number, Y: number, Width: number, Height: number, Parent: QuadTree = null) { @@ -348,11 +348,11 @@ module Phaser { /** * Load objects and/or groups into the quad tree, and register notify and processing callbacks. - * - * @param ObjectOrGroup1 Any object that is or extends GameObject or Group. - * @param ObjectOrGroup2 Any object that is or extends GameObject or Group. If null, the first parameter will be checked against itself. - * @param NotifyCallback A function with the form myFunction(Object1:GameObject,Object2:GameObject) that is called whenever two objects are found to overlap in world space, and either no ProcessCallback is specified, or the ProcessCallback returns true. - * @param ProcessCallback A function with the form myFunction(Object1:GameObject,Object2:GameObject):bool that is called whenever two objects are found to overlap in world space. The NotifyCallback is only called if this function returns true. See GameObject.separate(). + * + * @param {Basic} ObjectOrGroup1 Any object that is or extends GameObject or Group. + * @param {Basic} ObjectOrGroup2 Any object that is or extends GameObject or Group. If null, the first parameter will be checked against itself. + * @param {Function} NotifyCallback A function with the form myFunction(Object1:GameObject,Object2:GameObject) that is called whenever two objects are found to overlap in world space, and either no ProcessCallback is specified, or the ProcessCallback returns true. + * @param {Function} ProcessCallback A function with the form myFunction(Object1:GameObject,Object2:GameObject):bool that is called whenever two objects are found to overlap in world space. The NotifyCallback is only called if this function returns true. See GameObject.separate(). */ public load(ObjectOrGroup1: Basic, ObjectOrGroup2: Basic = null, NotifyCallback = null, ProcessCallback = null) { @@ -382,9 +382,9 @@ module Phaser { * Call this function to add an object to the root of the tree. * This function will recursively add all group members, but * not the groups themselves. - * - * @param ObjectOrGroup GameObjects are just added, Groups are recursed and their applicable members added accordingly. - * @param List A uint flag indicating the list to which you want to add the objects. Options are QuadTree.A_LIST and QuadTree.B_LIST. + * + * @param {Basic} ObjectOrGroup GameObjects are just added, Groups are recursed and their applicable members added accordingly. + * @param {Number} List A uint flag indicating the list to which you want to add the objects. Options are QuadTree.A_LIST and QuadTree.B_LIST. */ public add(ObjectOrGroup: Basic, List: number) { @@ -628,7 +628,7 @@ module Phaser { * QuadTree's other main function. Call this after adding objects * using QuadTree.load() to compare the objects that you loaded. * - * @return Whether or not any overlaps were found. + * @return {Boolean} Whether or not any overlaps were found. */ public execute(): bool { @@ -699,8 +699,8 @@ module Phaser { /** * An private for comparing an object against the contents of a node. - * - * @return Whether or not any overlaps were found. + * + * @return {Boolean} Whether or not any overlaps were found. */ private overlapNode(): bool { diff --git a/Phaser/system/input/Finger.ts b/Phaser/system/input/Finger.ts index fbf9555b..e518358b 100644 --- a/Phaser/system/input/Finger.ts +++ b/Phaser/system/input/Finger.ts @@ -10,7 +10,7 @@ module Phaser { export class Finger { - /** + /** * Constructor * @param {Phaser.Game} game. * @return {Phaser.Finger} This object. @@ -22,10 +22,10 @@ module Phaser { } - /** - * + /** + * * @property _game - * @type Phaser.Game + * @type {Phaser.Game} * @private **/ private _game: Game; @@ -33,154 +33,154 @@ module Phaser { /** * An identification number for each touch point. When a touch point becomes active, it must be assigned an identifier that is distinct from any other active touch point. While the touch point remains active, all events that refer to it must assign it the same identifier. * @property identifier - * @type Number + * @type {Number} */ public identifier: number; /** * * @property active - * @type Boolean + * @type {Boolean} */ public active: bool; - /** - * + /** + * * @property point - * @type Point + * @type {Point} **/ public point: Point = null; - /** - * + /** + * * @property circle - * @type Circle + * @type {Circle} **/ public circle: Circle = null; /** * * @property withinGame - * @type Boolean + * @type {Boolean} */ public withinGame: bool = false; /** * The horizontal coordinate of point relative to the viewport in pixels, excluding any scroll offset * @property clientX - * @type Number + * @type {Number} */ public clientX: number = -1; - // + // /** * The vertical coordinate of point relative to the viewport in pixels, excluding any scroll offset * @property clientY - * @type Number + * @type {Number} */ public clientY: number = -1; - // + // /** * The horizontal coordinate of point relative to the viewport in pixels, including any scroll offset * @property pageX - * @type Number + * @type {Number} */ public pageX: number = -1; /** * The vertical coordinate of point relative to the viewport in pixels, including any scroll offset * @property pageY - * @type Number + * @type {Number} */ public pageY: number = -1; /** * The horizontal coordinate of point relative to the screen in pixels * @property screenX - * @type Number + * @type {Number} */ public screenX: number = -1; /** * The vertical coordinate of point relative to the screen in pixels * @property screenY - * @type Number + * @type {Number} */ public screenY: number = -1; /** * The horizontal coordinate of point relative to the game element * @property x - * @type Number + * @type {Number} */ public x: number = -1; /** * The vertical coordinate of point relative to the game element * @property y - * @type Number + * @type {Number} */ public y: number = -1; /** * The Element on which the touch point started when it was first placed on the surface, even if the touch point has since moved outside the interactive area of that element. * @property target - * @type Any + * @type {Any} */ public target; - /** - * + /** + * * @property isDown - * @type Boolean + * @type {Boolean} **/ public isDown: bool = false; - /** - * + /** + * * @property isUp - * @type Boolean + * @type {Boolean} **/ public isUp: bool = false; - /** - * + /** + * * @property timeDown - * @type Number + * @type {Number} **/ public timeDown: number = 0; - /** - * + /** + * * @property duration - * @type Number + * @type {Number} **/ public duration: number = 0; - /** - * + /** + * * @property timeUp - * @type Number + * @type {Number} **/ public timeUp: number = 0; - /** - * + /** + * * @property justPressedRate - * @type Number + * @type {Number} **/ public justPressedRate: number = 200; - /** - * + /** + * * @property justReleasedRate - * @type Number + * @type {Number} **/ public justReleasedRate: number = 200; /** - * + * * @method start * @param {Any} event */ @@ -211,7 +211,7 @@ module Phaser { } /** - * + * * @method move * @param {Any} event */ @@ -237,7 +237,7 @@ module Phaser { } /** - * + * * @method leave * @param {Any} event */ @@ -249,7 +249,7 @@ module Phaser { } /** - * + * * @method stop * @param {Any} event */ @@ -265,10 +265,10 @@ module Phaser { } - /** - * + /** + * * @method justPressed - * @param {Number} [duration]. + * @param {Number} [duration]. * @return {Boolean} */ public justPressed(duration?: number = this.justPressedRate): bool { @@ -284,10 +284,10 @@ module Phaser { } - /** - * + /** + * * @method justReleased - * @param {Number} [duration]. + * @param {Number} [duration]. * @return {Boolean} */ public justReleased(duration?: number = this.justReleasedRate): bool { @@ -306,7 +306,7 @@ module Phaser { /** * Returns a string representation of this object. * @method toString - * @return {string} a string representation of the instance. + * @return {String} a string representation of the instance. **/ public toString(): string { diff --git a/Phaser/system/input/Input.ts b/Phaser/system/input/Input.ts index bde9380c..bcedecdc 100644 --- a/Phaser/system/input/Input.ts +++ b/Phaser/system/input/Input.ts @@ -26,20 +26,64 @@ module Phaser { private _game: Game; + /** + * + * @type {Mouse} + */ public mouse: Mouse; + /** + * + * @type {Keyboard} + */ public keyboard: Keyboard; + /** + * + * @type {Touch} + */ public touch: Touch; + /** + * + * @type {Number} + */ public x: number = 0; + /** + * + * @type {Number} + */ public y: number = 0; + /** + * + * @type {Number} + */ public scaleX: number = 1; + /** + * + * @type {Number} + */ public scaleY: number = 1; + /** + * + * @type {Number} + */ public worldX: number = 0; + /** + * + * @type {Number} + */ public worldY: number = 0; + /** + * + * @type {Phaser.Signal} + */ public onDown: Phaser.Signal; + /** + * + * @type {Phaser.Signal} + */ public onUp: Phaser.Signal; public update() { @@ -63,18 +107,29 @@ module Phaser { } + /** + * @param {Camera} [camera] + */ public getWorldX(camera?: Camera = this._game.camera) { return camera.worldView.x + this.x; } + /** + * @param {Camera} [camera] + */ public getWorldY(camera?: Camera = this._game.camera) { return camera.worldView.y + this.y; } + /** + * @param {Number} x + * @param {Number} y + * @param {String} [color] + */ public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') { this._game.stage.context.font = '14px Courier'; diff --git a/Phaser/system/input/Keyboard.ts b/Phaser/system/input/Keyboard.ts index e3415304..c269bab2 100644 --- a/Phaser/system/input/Keyboard.ts +++ b/Phaser/system/input/Keyboard.ts @@ -30,6 +30,9 @@ module Phaser { } + /** + * @param {Any} keycode + */ public addKeyCapture(keycode) { if (typeof keycode === 'object') @@ -46,6 +49,9 @@ module Phaser { } + /** + * @param {Number} keycode + */ public removeKeyCapture(keycode: number) { delete this._capture[keycode]; @@ -58,6 +64,9 @@ module Phaser { } + /** + * @param {KeyboardEvent} event + */ public onKeyDown(event: KeyboardEvent) { if (this._capture[event.keyCode]) @@ -77,6 +86,9 @@ module Phaser { } + /** + * @param {KeyboardEvent} event + */ public onKeyUp(event: KeyboardEvent) { if (this._capture[event.keyCode]) @@ -105,6 +117,11 @@ module Phaser { } + /** + * @param {Number} keycode + * @param {Number} [duration] + * @return {Boolean} + */ public justPressed(keycode: number, duration?: number = 250): bool { if (this._keys[keycode] && this._keys[keycode].isDown === true && (this._game.time.now - this._keys[keycode].timeDown < duration)) @@ -118,6 +135,11 @@ module Phaser { } + /** + * @param {Number} keycode + * @param {Number} [duration] + * @return {Boolean} + */ public justReleased(keycode: number, duration?: number = 250): bool { if (this._keys[keycode] && this._keys[keycode].isDown === false && (this._game.time.now - this._keys[keycode].timeUp < duration)) @@ -131,6 +153,10 @@ module Phaser { } + /** + * @param {Number} keycode + * @return {Boolean} + */ public isDown(keycode: number): bool { if (this._keys[keycode]) diff --git a/Phaser/system/input/Mouse.ts b/Phaser/system/input/Mouse.ts index e25eff5e..b882c822 100644 --- a/Phaser/system/input/Mouse.ts +++ b/Phaser/system/input/Mouse.ts @@ -28,10 +28,25 @@ module Phaser { public static MIDDLE_BUTTON: number = 1; public static RIGHT_BUTTON: number = 2; + /** + * @type {Boolean} + */ public isDown: bool = false; + /** + * @type {Boolean} + */ public isUp: bool = true; + /** + * @type {Number} + */ public timeDown: number = 0; + /** + * @type {Number} + */ public duration: number = 0; + /** + * @type {Number} + */ public timeUp: number = 0; public start() { @@ -49,6 +64,9 @@ module Phaser { } + /** + * @param {MouseEvent} event + */ public onMouseDown(event: MouseEvent) { this.button = event.button; @@ -79,6 +97,9 @@ module Phaser { } + /** + * @param {MouseEvent} event + */ public onMouseMove(event: MouseEvent) { this.button = event.button; @@ -91,6 +112,9 @@ module Phaser { } + /** + * @param {MouseEvent} event + */ public onMouseUp(event: MouseEvent) { this.button = event.button; diff --git a/Phaser/system/input/Touch.ts b/Phaser/system/input/Touch.ts index 45d876c3..fa2a0ae6 100644 --- a/Phaser/system/input/Touch.ts +++ b/Phaser/system/input/Touch.ts @@ -21,7 +21,7 @@ module Phaser { export class Touch { - /** + /** * Constructor * @param {Game} game. * @return {Touch} This object. @@ -50,133 +50,133 @@ module Phaser { } - /** - * + /** + * * @property _game - * @type Game + * @type {Game} * @private **/ private _game: Game; - /** - * + /** + * * @property x - * @type Number + * @type {Number} **/ public x: number = 0; - /** - * + /** + * * @property y - * @type Number + * @type {Number} **/ public y: number = 0; - /** - * + /** + * * @property _fingers - * @type Array + * @type {Array} * @private **/ private _fingers: Finger[]; - /** - * + /** + * * @property finger1 - * @type Finger + * @type {Finger} **/ public finger1: Finger; - /** - * + /** + * * @property finger2 - * @type Finger + * @type {Finger} **/ public finger2: Finger; - /** - * + /** + * * @property finger3 - * @type Finger + * @type {Finger} **/ public finger3: Finger; - /** - * + /** + * * @property finger4 - * @type Finger + * @type {Finger} **/ public finger4: Finger; - /** - * + /** + * * @property finger5 - * @type Finger + * @type {Finger} **/ public finger5: Finger; - /** - * + /** + * * @property finger6 - * @type Finger + * @type {Finger} **/ public finger6: Finger; - /** - * + /** + * * @property finger7 - * @type Finger + * @type {Finger} **/ public finger7: Finger; - /** - * + /** + * * @property finger8 - * @type Finger + * @type {Finger} **/ public finger8: Finger; - /** - * + /** + * * @property finger9 - * @type Finger + * @type {Finger} **/ public finger9: Finger; - /** - * + /** + * * @property finger10 - * @type Finger + * @type {Finger} **/ public finger10: Finger; - /** - * + /** + * * @property latestFinger - * @type Finger + * @type {Finger} **/ public latestFinger: Finger; - /** - * + /** + * * @property isDown - * @type Boolean + * @type {Boolean} **/ public isDown: bool = false; - /** - * + /** + * * @property isUp - * @type Boolean + * @type {Boolean} **/ public isUp: bool = true; public touchDown: Signal; public touchUp: Signal; - /** - * - * @method start + /** + * + * @method start */ public start() { @@ -191,7 +191,7 @@ module Phaser { } - /** + /** * Prevent iOS bounce-back (doesn't work?) * @method consumeTouchMove * @param {Any} event @@ -202,8 +202,8 @@ module Phaser { } - /** - * + /** + * * @method onTouchStart * @param {Any} event **/ @@ -239,7 +239,7 @@ module Phaser { } - /** + /** * Doesn't appear to be supported by most browsers yet * @method onTouchCancel * @param {Any} event @@ -265,7 +265,7 @@ module Phaser { } - /** + /** * Doesn't appear to be supported by most browsers yet * @method onTouchEnter * @param {Any} event @@ -293,7 +293,7 @@ module Phaser { } - /** + /** * Doesn't appear to be supported by most browsers yet * @method onTouchLeave * @param {Any} event @@ -319,8 +319,8 @@ module Phaser { } - /** - * + /** + * * @method onTouchMove * @param {Any} event **/ @@ -349,8 +349,8 @@ module Phaser { } - /** - * + /** + * * @method onTouchEnd * @param {Any} event **/ @@ -384,8 +384,8 @@ module Phaser { } - /** - * + /** + * * @method calculateDistance * @param {Finger} finger1 * @param {Finger} finger2 @@ -393,8 +393,8 @@ module Phaser { public calculateDistance(finger1: Finger, finger2: Finger) { } - /** - * + /** + * * @method calculateAngle * @param {Finger} finger1 * @param {Finger} finger2 @@ -402,8 +402,8 @@ module Phaser { public calculateAngle(finger1: Finger, finger2: Finger) { } - /** - * + /** + * * @method checkOverlap * @param {Finger} finger1 * @param {Finger} finger2 @@ -411,18 +411,18 @@ module Phaser { public checkOverlap(finger1: Finger, finger2: Finger) { } - /** - * - * @method update + /** + * + * @method update */ public update() { } - /** - * - * @method stop + /** + * + * @method stop */ public stop() { @@ -435,8 +435,8 @@ module Phaser { } - /** - * + /** + * * @method reset **/ public reset() {