Skip to content

Commit 5cf8b84

Browse files
pixelpicoseanphotonstorm
authored andcommitted
Finish another 10 classes' document.
1 parent 9da64e6 commit 5cf8b84

10 files changed

Lines changed: 667 additions & 68 deletions

File tree

Phaser/gameobjects/GameObject.ts

Lines changed: 283 additions & 57 deletions
Large diffs are not rendered by default.

Phaser/system/Sound.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ module Phaser {
1111

1212
export class Sound {
1313

14+
/**
15+
* Sound constructor
16+
* @param context The AudioContext instance.
17+
* @param gainNode Gain node instance.
18+
* @param data Sound data.
19+
* @param volume Optional, volume of this sound when playing.
20+
* @param loop Optional, loop this sound when playing? (Default to false)
21+
*/
1422
constructor(context, gainNode, data, volume?: number = 1, loop?: bool = false) {
1523

1624
this._context = context;
@@ -38,11 +46,29 @@ module Phaser {
3846

3947
}
4048

49+
/**
50+
* Local private reference to AudioContext.
51+
*/
4152
private _context;
53+
/**
54+
* Reference to gain node of SoundManager.
55+
*/
4256
private _gainNode;
57+
/**
58+
* GainNode of this sound.
59+
*/
4360
private _localGainNode;
61+
/**
62+
* Decoded data buffer.
63+
*/
4464
private _buffer;
65+
/**
66+
* Volume of this sound.
67+
*/
4568
private _volume: number;
69+
/**
70+
* The real sound object (buffer source).
71+
*/
4672
private _sound;
4773

4874
loop: bool = false;
@@ -58,6 +84,9 @@ module Phaser {
5884

5985
}
6086

87+
/**
88+
* Play this sound.
89+
*/
6190
public play() {
6291

6392
if (this._buffer === null || this.isDecoding === true)
@@ -81,6 +110,9 @@ module Phaser {
81110

82111
}
83112

113+
/**
114+
* Stop playing this sound.
115+
*/
84116
public stop() {
85117

86118
if (this.isPlaying === true)
@@ -92,12 +124,18 @@ module Phaser {
92124

93125
}
94126

127+
/**
128+
* Mute the sound.
129+
*/
95130
public mute() {
96131

97132
this._localGainNode.gain.value = 0;
98133

99134
}
100135

136+
/**
137+
* Enable the sound.
138+
*/
101139
public unmute() {
102140

103141
this._localGainNode.gain.value = this._volume;

Phaser/system/StageScaleMode.ts

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ module Phaser {
1212

1313
export class StageScaleMode {
1414

15+
/**
16+
* StageScaleMode constructor
17+
*/
1518
constructor(game: Game) {
1619

1720
this._game = game;
@@ -22,23 +25,51 @@ module Phaser {
2225

2326
}
2427

28+
/**
29+
* Local private reference to game.
30+
*/
2531
private _game: Game;
32+
/**
33+
* Stage height when start the game.
34+
* @type {number}
35+
*/
2636
private _startHeight: number = 0;
2737
private _iterations: number;
2838
private _check;
2939

30-
// Specifies that the game be visible in the specified area without trying to preserve the original aspect ratio.
40+
/**
41+
* Specifies that the game be visible in the specified area without trying to preserve the original aspect ratio.
42+
* @type {number}
43+
*/
3144
public static EXACT_FIT: number = 0;
3245

33-
// Specifies that the size of the game be fixed, so that it remains unchanged even if the size of the window changes.
46+
/**
47+
* Specifies that the size of the game be fixed, so that it remains unchanged even if the size of the window changes.
48+
* @type {number}
49+
*/
3450
public static NO_SCALE: number = 1;
3551

36-
// Specifies that the entire game be visible in the specified area without distortion while maintaining the original aspect ratio.
52+
/**
53+
* Specifies that the entire game be visible in the specified area without distortion while maintaining the original aspect ratio.
54+
* @type {number}
55+
*/
3756
public static SHOW_ALL: number = 2;
3857

58+
/**
59+
* Width of the stage after calculation.
60+
* @type {number}
61+
*/
3962
public width: number = 0;
63+
/**
64+
* Height of the stage after calculation.
65+
* @type {number}
66+
*/
4067
public height: number = 0;
4168

69+
/**
70+
* Game orientation angel.
71+
* @type {number}
72+
*/
4273
public orientation;
4374

4475
public update() {
@@ -54,6 +85,9 @@ module Phaser {
5485
return window['orientation'] === 90 || window['orientation'] === -90;
5586
}
5687

88+
/**
89+
* Check whether game orientation the same as window's. Update orientation if not equal.
90+
*/
5791
private checkOrientation(event) {
5892

5993
if (window['orientation'] !== this.orientation)
@@ -64,6 +98,9 @@ module Phaser {
6498

6599
}
66100

101+
/**
102+
* Re-calculate scale mode and update screen size.
103+
*/
67104
private refresh() {
68105

69106
// We can't do anything about the status bars in iPads, web apps or desktops
@@ -91,6 +128,9 @@ module Phaser {
91128

92129
}
93130

131+
/**
132+
* Set screen size automatically based on stage's scaleMode.
133+
*/
94134
private setScreenSize() {
95135

96136
if (this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false)

Phaser/system/Tile.ts

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ module Phaser {
1010

1111
export class Tile {
1212

13+
/**
14+
* Tile constructor
15+
* Create a new <code>Tile</code>.
16+
*
17+
* @param tilemap the tilemap this tile belongs to.
18+
* @param index The index of this tile type in the core map data.
19+
* @param width Width of the tile.
20+
* @param height Height of the tile.
21+
*/
1322
constructor(game: Game, tilemap: Tilemap, index: number, width: number, height: number) {
1423

1524
this._game = game;
@@ -22,34 +31,82 @@ module Phaser {
2231

2332
}
2433

34+
/**
35+
* Local private reference to game.
36+
*/
2537
private _game: Game;
2638

27-
// You can give this Tile a friendly name to help with debugging. Never used internally.
39+
/**
40+
* You can give this Tile a friendly name to help with debugging. Never used internally.
41+
* @type {string}
42+
*/
2843
public name: string;
2944

45+
/**
46+
* The virtual mass of the tile.
47+
* @type {number}
48+
*/
3049
public mass: number = 1.0;
50+
/**
51+
* Tile width.
52+
* @type {number}
53+
*/
3154
public width: number;
55+
/**
56+
* Tile height.
57+
* @type {number}
58+
*/
3259
public height: number;
3360

61+
/**
62+
* Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions.
63+
* @type {number}
64+
*/
3465
public allowCollisions: number;
3566

67+
/**
68+
* Indicating collide with any object on the left.
69+
* @type {boolean}
70+
*/
3671
public collideLeft: bool = false;
72+
/**
73+
* Indicating collide with any object on the right.
74+
* @type {boolean}
75+
*/
3776
public collideRight: bool = false;
77+
/**
78+
* Indicating collide with any object on the top.
79+
* @type {boolean}
80+
*/
3881
public collideUp: bool = false;
82+
/**
83+
* Indicating collide with any object on the bottom.
84+
* @type {boolean}
85+
*/
3986
public collideDown: bool = false;
4087

88+
/**
89+
* Enable separation at x-axis.
90+
* @type {boolean}
91+
*/
4192
public separateX: bool = true;
93+
/**
94+
* Enable separation at y-axis.
95+
* @type {boolean}
96+
*/
4297
public separateY: bool = true;
4398

4499
/**
45100
* A reference to the tilemap this tile object belongs to.
101+
* @type {Tilemap}
46102
*/
47103
public tilemap: Tilemap;
48104

49105
/**
50106
* The index of this tile type in the core map data.
51107
* For example, if your map only has 16 kinds of tiles in it,
52108
* this number is usually between 0 and 15.
109+
* @type {number}
53110
*/
54111
public index: number;
55112

@@ -62,6 +119,13 @@ module Phaser {
62119

63120
}
64121

122+
/**
123+
* Set collision configs.
124+
* @param collision Bit field of flags. (see Tile.allowCollision)
125+
* @param resetCollisions Reset collision flags before set.
126+
* @param separateX Enable seprate at x-axis.
127+
* @param separateY Enable seprate at y-axis.
128+
*/
65129
public setCollision(collision: number, resetCollisions: bool, separateX: bool, separateY: bool) {
66130

67131
if (resetCollisions)
@@ -105,6 +169,9 @@ module Phaser {
105169

106170
}
107171

172+
/**
173+
* Reset collision status flags.
174+
*/
108175
public resetCollision() {
109176

110177
this.allowCollisions = Collision.NONE;

Phaser/system/animation/Animation.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ module Phaser {
1010

1111
export class Animation {
1212

13+
/**
14+
* Animation constructor
15+
* Create a new <code>Animation</code>.
16+
*
17+
* @param width Width of the world bound.
18+
* @param height Height of the world bound.
19+
*/
1320
constructor(game: Game, parent: Sprite, frameData: FrameData, name: string, frames, delay: number, looped: bool) {
1421

1522
this._game = game;

Phaser/system/animation/AnimationLoader.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ module Phaser {
1010

1111
export class AnimationLoader {
1212

13+
/**
14+
* Parse a sprite sheet from asset data.
15+
* @param key Asset key for the sprite sheet data.
16+
* @param frameWidth Width of animation frame.
17+
* @param frameHeight Height of animation frame.
18+
* @param frameMax Number of animation frames.
19+
* @return {FrameData=} Generated FrameData object.
20+
*/
1321
public static parseSpriteSheet(game: Game, key: string, frameWidth: number, frameHeight: number, frameMax: number): FrameData {
1422

1523
// How big is our image?
@@ -63,6 +71,11 @@ module Phaser {
6371

6472
}
6573

74+
/**
75+
* Parse frame datas from json.
76+
* @param json Json data you want to parse.
77+
* @return {FrameData=} Generated FrameData object.
78+
*/
6679
public static parseJSONData(game: Game, json): FrameData {
6780

6881
// Let's create some frames then

0 commit comments

Comments
 (0)