Finish documents for GameObject, World, TweenManager, State, Stage.

This commit is contained in:
Sean 2013-05-04 19:34:05 +08:00 committed by Richard Davey
parent 5cf8b846f8
commit 4be5a10e44
5 changed files with 127 additions and 128 deletions

View file

@ -20,9 +20,9 @@ module Phaser {
*
* Create a new <code>Stage</code> with specific width and height.
*
* @param parent ID of parent DOM element.
* @param width Width of the stage.
* @param height Height of the stage.
* @param parent {number} ID of parent DOM element.
* @param width {number} Width of the stage.
* @param height {number} Height of the stage.
*/
constructor(game: Game, parent: string, width: number, height: number) {

View file

@ -12,7 +12,6 @@ module Phaser {
/**
* State constructor
*
* Create a new <code>State</code>.
*/
constructor(game: Game) {
@ -130,11 +129,11 @@ module Phaser {
/**
* Create a new camera with specific position and size.
*
* @param x X position of the new camera.
* @param y Y position of the new camera.
* @param width Width of the new camera.
* @param height Height of the new camera.
* @returns {Camera=} The newly created camera object.
* @param x {number} X position of the new camera.
* @param y {number} Y position of the new camera.
* @param width {number} Width of the new camera.
* @param height {number} Height of the new camera.
* @returns {Camera} The newly created camera object.
*/
public createCamera(x: number, y: number, width: number, height: number): Camera {
return this.game.world.createCamera(x, y, width, height);
@ -143,9 +142,9 @@ module Phaser {
/**
* Create a new GeomSprite with specific position.
*
* @param x X position of the new geom sprite.
* @param y Y position of the new geom sprite.
* @returns {GeomSprite=} The newly created geom sprite object.
* @param x {number} X position of the new geom sprite.
* @param y {number} Y position of the new geom sprite.
* @returns {GeomSprite} The newly created geom sprite object.
*/
public createGeomSprite(x: number, y: number): GeomSprite {
return this.world.createGeomSprite(x, y);
@ -154,10 +153,10 @@ module Phaser {
/**
* Create a new Sprite with specific position and sprite sheet key.
*
* @param x X position of the new sprite.
* @param y Y position of the new sprite.
* @param key Optinal, key for the sprite sheet you want it to use.
* @returns {Sprite=} The newly created sprite object.
* @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.
* @returns {Sprite} The newly created sprite object.
*/
public createSprite(x: number, y: number, key?: string = ''): Sprite {
return this.game.world.createSprite(x, y, key);
@ -166,9 +165,9 @@ module Phaser {
/**
* Create a new DynamicTexture with specific size.
*
* @param width Width of the texture.
* @param height Height of the texture.
* @returns {DynamicTexture=} The newly created dynamic texture object.
* @param width {number} Width of the texture.
* @param height {number} Height of the texture.
* @returns {DynamicTexture} The newly created dynamic texture object.
*/
public createDynamicTexture(width: number, height: number): DynamicTexture {
return this.game.world.createDynamicTexture(width, height);
@ -177,8 +176,8 @@ module Phaser {
/**
* Create a new object container.
*
* @param MaxSize Optinal, capacity of this group.
* @returns {Group=} The newly created group.
* @param MaxSize {number} Optinal, capacity of this group.
* @returns {Group} The newly created group.
*/
public createGroup(MaxSize?: number = 0): Group {
return this.game.world.createGroup(MaxSize);
@ -187,7 +186,7 @@ module Phaser {
/**
* Create a new Particle.
*
* @return {Particle=} The newly created particle object.
* @return {Particle} The newly created particle object.
*/
public createParticle(): Particle {
return this.game.world.createParticle();
@ -196,10 +195,10 @@ module Phaser {
/**
* Create a new Emitter.
*
* @param x Optinal, x position of the emitter.
* @param y Optinal, y position of the emitter.
* @param size Optinal, size of this emitter.
* @return {Emitter=} The newly created emitter object.
* @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.
* @return {Emitter} The newly created emitter object.
*/
public createEmitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
return this.game.world.createEmitter(x, y, size);
@ -208,12 +207,12 @@ module Phaser {
/**
* Create a new ScrollZone object with image key, position and size.
*
* @param key Key to a image you wish this object to use.
* @param x X position of this object.
* @param y Y position of this object.
* @param width Width of this object.
* @param height Heigth of this object.
* @returns {ScrollZone=} The newly created scroll zone object.
* @param key {string} Key to a image you wish this object to use.
* @param x {number} X position of this object.
* @param y {number} Y position of this object.
* @param width {number} Width of this object.
* @param height {number} Heigth of this object.
* @returns {ScrollZone} The newly created scroll zone object.
*/
public createScrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
return this.game.world.createScrollZone(key, x, y, width, height);
@ -222,13 +221,13 @@ module Phaser {
/**
* Create a new Tilemap.
*
* @param key Key for tileset image.
* @param mapData Data of this tilemap.
* @param format Format of map data. (Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON)
* @param resizeWorld Optinal, resize the world to make same as tilemap?
* @param tileWidth Optinal, width of each tile.
* @param tileHeight Optinal, height of each tile.
* @return {Tilemap=} The newly created tilemap object.
* @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.
* @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 {
return this.game.world.createTilemap(key, mapData, format, resizeWorld, tileWidth, tileHeight);
@ -237,8 +236,8 @@ module Phaser {
/**
* Create a tween object for a specific object.
*
* @param obj Object you wish the tween will affect.
* @return {Phaser.Tween=} The newly created tween object.
* @param obj Object you wish the tween will affect.
* @return {Phaser.Tween} The newly created tween object.
*/
public createTween(obj): Tween {
return this.game.tweens.create(obj);

View file

@ -17,7 +17,7 @@ module Phaser {
/**
* TweenManager constructor
* @param game A reference to the current Game.
* @param game {Game} A reference to the current Game.
*/
constructor(game: Phaser.Game) {
@ -37,7 +37,7 @@ module Phaser {
/**
* Get all the tween objects in an array.
* @return {array=} Array with all tween objects.
* @return {Phaser.Tween[]} Array with all tween objects.
*/
public getAll() {
@ -57,8 +57,8 @@ module Phaser {
/**
* Create a tween object for a specific object.
*
* @param object Object you wish the tween will affect.
* @return {Phaser.Tween=} The newly created tween object.
* @param object {object} Object you wish the tween will affect.
* @return {Phaser.Tween} The newly created tween object.
*/
public create(object): Phaser.Tween {
@ -69,7 +69,7 @@ module Phaser {
/**
* Add an exist tween object to the manager.
*
* @param tween The tween object you want to add.
* @param tween {Phaser.Tween} The tween object you want to add.
* @return {Phaser.Tween} The tween object you added to the manager.
*/
public add(tween: Phaser.Tween) {
@ -85,7 +85,7 @@ module Phaser {
/**
* Remove a tween from this manager.
*
* @param tween The tween object you want to remove.
* @param tween {Phaser.Tween} The tween object you want to remove.
*/
public remove(tween: Phaser.Tween) {

View file

@ -16,8 +16,8 @@ module Phaser {
* World constructor
* Create a new <code>World</code> with specific width and height.
*
* @param width Width of the world bound.
* @param height Height of the world bound.
* @param width {number} Width of the world bound.
* @param height {number} Height of the world bound.
*/
constructor(game: Game, width: number, height: number) {
@ -100,9 +100,9 @@ module Phaser {
* Update size of this world with specific width and height.
* You can choose update camera bounds automatically or not.
*
* @param width New width of the world.
* @param height New height of the world.
* @param updateCameraBounds Optinal, update camera bounds automatically or not. Default to true.
* @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.
*/
public setSize(width: number, height: number, updateCameraBounds: bool = true) {
@ -153,11 +153,11 @@ module Phaser {
/**
* Create a new camera with specific position and size.
*
* @param x X position of the new camera.
* @param y Y position of the new camera.
* @param width Width of the new camera.
* @param height Height of the new camera.
* @returns {Camera=} The newly created camera object.
* @param x {number} X position of the new camera.
* @param y {number} Y position of the new camera.
* @param width {number} Width of the new camera.
* @param height {number} Height of the new camera.
* @returns {Camera} The newly created camera object.
*/
public createCamera(x: number, y: number, width: number, height: number): Camera {
return this.cameras.addCamera(x, y, width, height);
@ -166,8 +166,8 @@ module Phaser {
/**
* Remove a new camera with its id.
*
* @param id ID of the camera you want to remove.
* @returns {boolean} True if successfully removed the camera, otherwise return false.
* @param id {number} ID of the camera you want to remove.
* @returns {boolean} True if successfully removed the camera, otherwise return false.
*/
public removeCamera(id: number): bool {
return this.cameras.removeCamera(id);
@ -187,10 +187,10 @@ module Phaser {
/**
* Create a new Sprite with specific position and sprite sheet key.
*
* @param x X position of the new sprite.
* @param y Y position of the new sprite.
* @param key Optinal, key for the sprite sheet you want it to use.
* @returns {Sprite=} The newly created sprite object.
* @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.
* @returns {Sprite} The newly created sprite object.
*/
public createSprite(x: number, y: number, key?: string = ''): Sprite {
return <Sprite> this.group.add(new Sprite(this._game, x, y, key));
@ -199,9 +199,9 @@ module Phaser {
/**
* Create a new GeomSprite with specific position.
*
* @param x X position of the new geom sprite.
* @param y Y position of the new geom sprite.
* @returns {GeomSprite=} The newly created geom sprite object.
* @param x {number} X position of the new geom sprite.
* @param y {number} Y position of the new geom sprite.
* @returns {GeomSprite} The newly created geom sprite object.
*/
public createGeomSprite(x: number, y: number): GeomSprite {
return <GeomSprite> this.group.add(new GeomSprite(this._game, x, y));
@ -210,9 +210,9 @@ module Phaser {
/**
* Create a new DynamicTexture with specific size.
*
* @param width Width of the texture.
* @param height Height of the texture.
* @returns {DynamicTexture=} The newly created dynamic texture object.
* @param width {number} Width of the texture.
* @param height {number} Height of the texture.
* @returns {DynamicTexture} The newly created dynamic texture object.
*/
public createDynamicTexture(width: number, height: number): DynamicTexture {
return new DynamicTexture(this._game, width, height);
@ -221,8 +221,8 @@ module Phaser {
/**
* Create a new object container.
*
* @param MaxSize Optinal, capacity of this group.
* @returns {Group=} The newly created group.
* @param MaxSize {number} Optinal, capacity of this group.
* @returns {Group} The newly created group.
*/
public createGroup(MaxSize?: number = 0): Group {
return <Group> this.group.add(new Group(this._game, MaxSize));
@ -231,12 +231,12 @@ module Phaser {
/**
* Create a new ScrollZone object with image key, position and size.
*
* @param key Key to a image you wish this object to use.
* @param x X position of this object.
* @param y Y position of this object.
* @param width Width of this object.
* @param height Heigth of this object.
* @returns {ScrollZone=} The newly created scroll zone object.
* @param key {number} Key to a image you wish this object to use.
* @param x {number} X position of this object.
* @param y {number} Y position of this object.
* @param width {number} Width of this object.
* @param height {number} Heigth of this object.
* @returns {ScrollZone} The newly created scroll zone object.
*/
public createScrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
return <ScrollZone> this.group.add(new ScrollZone(this._game, key, x, y, width, height));
@ -245,13 +245,13 @@ module Phaser {
/**
* Create a new Tilemap.
*
* @param key Key for tileset image.
* @param mapData Data of this tilemap.
* @param format Format of map data. (Tilemap.FORMAT_CSV or Tilemap.FORMAT_TILED_JSON)
* @param resizeWorld Optinal, resize the world to make same as tilemap?
* @param tileWidth Optinal, width of each tile.
* @param tileHeight Optinal, height of each tile.
* @return {Tilemap=} The newly created tilemap object.
* @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.
* @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 {
return <Tilemap> this.group.add(new Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
@ -260,7 +260,7 @@ module Phaser {
/**
* Create a new Particle.
*
* @return {Particle=} The newly created particle object.
* @return {Particle} The newly created particle object.
*/
public createParticle(): Particle {
return new Particle(this._game);
@ -269,10 +269,10 @@ module Phaser {
/**
* Create a new Emitter.
*
* @param x Optinal, x position of the emitter.
* @param y Optinal, y position of the emitter.
* @param size Optinal, size of this emitter.
* @return {Emitter=} The newly created emitter object.
* @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.
* @return {Emitter} The newly created emitter object.
*/
public createEmitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
return <Emitter> this.group.add(new Emitter(this._game, x, y, size));

View file

@ -19,10 +19,10 @@ module Phaser {
* Create a new <code>GameObject</code> object at specific position with
* specific width and height.
*
* @param x Optinal, the x position of the object.
* @param y Optinal, the y position of the object.
* @param width Optinal, the width of the object.
* @param height Optinal, the height of the object.
* @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.
*/
constructor(game: Game, x?: number = 0, y?: number = 0, width?: number = 16, height?: number = 16) {
@ -421,11 +421,11 @@ module Phaser {
* If the group has a LOT of things in it, it might be faster to use <code>Collision.overlaps()</code>.
* WARNING: Currently tilemaps do NOT support screen space overlap checks!
*
* @param ObjectOrGroup The object or group being tested.
* @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
* @param ObjectOrGroup {object} The object or group being tested.
* @param InScreenSpace {boolean} Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
* @param Camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return Whether or not the two objects overlap.
* @return {boolean} Whether or not the objects overlap this.
*/
public overlaps(ObjectOrGroup, InScreenSpace: bool = false, Camera: Camera = null): bool {
@ -471,13 +471,13 @@ module Phaser {
* This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size numbero account.
* WARNING: Currently tilemaps do NOT support screen space overlap checks!
*
* @param X The X position you want to check. Pretends this object (the caller, not the parameter) is located here.
* @param Y The Y position you want to check. Pretends this object (the caller, not the parameter) is located here.
* @param ObjectOrGroup The object or group being tested.
* @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
* @param X {number} The X position you want to check. Pretends this object (the caller, not the parameter) is located here.
* @param Y {number} The Y position you want to check. Pretends this object (the caller, not the parameter) is located here.
* @param ObjectOrGroup {object} The object or group being tested.
* @param InScreenSpace {boolean} Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
* @param Camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return Whether or not the two objects overlap.
* @return {boolean} Whether or not the two objects overlap.
*/
public overlapsAt(X: number, Y: number, ObjectOrGroup, InScreenSpace: bool = false, Camera: Camera = null): bool {
@ -524,9 +524,9 @@ module Phaser {
/**
* Checks to see if a point in 2D world space overlaps this <code>GameObject</code>.
*
* @param Point The point in world space you want to check.
* @param InScreenSpace Whether to take scroll factors into account when checking for overlap.
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
* @param point {Point} The point in world space you want to check.
* @param InScreenSpace {boolean} Whether to take scroll factors into account when checking for overlap.
* @param Camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return Whether or not the point overlaps this object.
*/
@ -554,9 +554,9 @@ module Phaser {
/**
* Check and see if this object is currently on screen.
*
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
* @param Camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return Whether the object is on screen or not.
* @return {boolean} Whether the object is on screen or not.
*/
public onScreen(Camera: Camera = null): bool {
@ -574,10 +574,10 @@ module Phaser {
/**
* Call this to figure out the on-screen position of the object.
*
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
* @param Point Takes a <code>MicroPoint</code> object and assigns the post-scrolled X and Y values of this object to it.
* @param Point {Point} Takes a <code>MicroPoint</code> object and assigns the post-scrolled X and Y values of this object to it.
* @param Camera {Camera} Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return The <code>MicroPoint</code> you passed in, or a new <code>Point</code> if you didn't pass one, containing the screen X and Y position of this object.
* @return {MicroPoint} The <code>MicroPoint</code> you passed in, or a new <code>Point</code> if you didn't pass one, containing the screen X and Y position of this object.
*/
public getScreenXY(point: MicroPoint = null, Camera: Camera = null): MicroPoint {
@ -625,9 +625,9 @@ module Phaser {
/**
* Retrieve the midpoint of this object in world coordinates.
*
* @Point Allows you to pass in an existing <code>Point</code> object if you're so inclined. Otherwise a new one is created.
* @param point {Point} Allows you to pass in an existing <code>Point</code> object if you're so inclined. Otherwise a new one is created.
*
* @return A <code>Point</code> object containing the midpoint of this object in world coordinates.
* @return {MicroPoint} A <code>Point</code> object containing the midpoint of this object in world coordinates.
*/
public getMidpoint(point: MicroPoint = null): MicroPoint {
@ -646,8 +646,8 @@ module Phaser {
* Handy for reviving game objects.
* Resets their existence flags and position.
*
* @param X The new X position of this object.
* @param Y The new Y position of this object.
* @param X {number} The new X position of this object.
* @param Y {number} The new Y position of this object.
*/
public reset(X: number, Y: number) {
@ -668,9 +668,9 @@ module Phaser {
* For slightly better performance you can just &amp; the value directly numbero <code>touching</code>.
* However, this method is good for readability and accessibility.
*
* @param Direction Any of the collision flags (e.g. LEFT, FLOOR, etc).
* @param Direction {number} Any of the collision flags (e.g. LEFT, FLOOR, etc).
*
* @return Whether the object is touching an object in (any of) the specified direction(s) this frame.
* @return {boolean} Whether the object is touching an object in (any of) the specified direction(s) this frame.
*/
public isTouching(Direction: number): bool {
return (this.touching & Direction) > Collision.NONE;
@ -679,17 +679,17 @@ module Phaser {
/**
* Handy for checking if this object is just landed on a particular surface.
*
* @param Direction Any of the collision flags (e.g. LEFT, FLOOR, etc).
* @param {number} Direction Any of the collision flags (e.g. LEFT, FLOOR, etc).
*
* @return Whether the object just landed on (any of) the specified surface(s) this frame.
* @return {boolean} Whether the object just landed on (any of) the specified surface(s) this frame.
*/
/**
* Handy function for checking if this object is just landed on a particular surface.
*
* @param Direction Any of the collision flags (e.g. LEFT, FLOOR, etc).
* @param Direction {number} Any of the collision flags (e.g. LEFT, FLOOR, etc).
*
* @returns bool Whether the object just landed on any specicied surfaces.
* @returns {boolean} Whether the object just landed on any specicied surfaces.
*/
public justTouched(Direction: number): bool {
return ((this.touching & Direction) > Collision.NONE) && ((this.wasTouching & Direction) <= Collision.NONE);
@ -699,7 +699,7 @@ module Phaser {
* Reduces the "health" variable of this sprite by the amount specified in Damage.
* Calls kill() if health drops to or below zero.
*
* @param Damage How much health to take away (use a negative number to give a health bonus).
* @param Damage {number} How much health to take away (use a negative number to give a health bonus).
*/
public hurt(Damage: number) {
@ -717,10 +717,10 @@ module Phaser {
* in the world. But by setting the bounds (which are given in world dimensions, not screen dimensions)
* it can be stopped from leaving the world, or a section of it.
*
* @param x x position of the bound
* @param y y position of the bound
* @param width width of its bound
* @param height height of its bound
* @param x {number} x position of the bound
* @param y {number} y position of the bound
* @param width {number} width of its bound
* @param height {number} height of its bound
*/
public setBounds(x: number, y: number, width: number, height: number) {
@ -731,7 +731,7 @@ module Phaser {
/**
* If you do not wish this object to be visible to a specific camera, pass the camera here.
* @param camera The specific camera.
* @param camera {Camera} The specific camera.
*/
public hideFromCamera(camera: Camera) {
@ -746,7 +746,7 @@ module Phaser {
/**
* Make this object only visible to a specific camera.
*
* @param camera The camera you wish it to be visible.
* @param camera {Camera} The camera you wish it to be visible.
*/
public showToCamera(camera: Camera) {