Simply add type info to jsdoc of these classs.

This commit is contained in:
Sean
2013-05-12 00:26:30 +08:00
parent 0adbf1d92f
commit 1c311a73df
14 changed files with 519 additions and 393 deletions
+56 -56
View File
@@ -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 {
+55
View File
@@ -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';
+26
View File
@@ -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])
+24
View File
@@ -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;
+79 -79
View File
@@ -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() {