Skip to content

Commit 4ec82f1

Browse files
author
Nio Kasgami
authored
Added docs
Added documentations to the Scene_Base class.
1 parent 78dc892 commit 4ec82f1

File tree

1 file changed

+162
-3
lines changed

1 file changed

+162
-3
lines changed

js/rpg_scenes/Scene_Base.js

Lines changed: 162 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
1+
/=============================================================================
2+
// ■ Scene_Base V.1.4.0 (community-1.1b)
13
//-----------------------------------------------------------------------------
2-
// Scene_Base
3-
//
4-
// The superclass of all scenes within the game.
54

5+
/**
6+
* The Superclass of all scene within the game.
7+
*
8+
* @class Scene_Base
9+
* @constructor
10+
* @extends Stage
11+
*/
612
function Scene_Base() {
713
this.initialize.apply(this, arguments);
814
}
915

1016
Scene_Base.prototype = Object.create(Stage.prototype);
1117
Scene_Base.prototype.constructor = Scene_Base;
1218

19+
20+
/**
21+
* Create a instance of Scene_Base.
22+
*
23+
* @constructor
24+
* @memberof Scene_Base
25+
*/
1326
Scene_Base.prototype.initialize = function() {
1427
Stage.prototype.initialize.call(this);
1528
this._active = false;
@@ -19,45 +32,115 @@ Scene_Base.prototype.initialize = function() {
1932
this._imageReservationId = Utils.generateRuntimeId();
2033
};
2134

35+
/**
36+
* Attach a reservation to the reserve queue.
37+
*
38+
* @method attachReservation
39+
* @memberof Scene_Base
40+
*/
2241
Scene_Base.prototype.attachReservation = function() {
2342
ImageManager.setDefaultReservationId(this._imageReservationId);
2443
};
2544

45+
/**
46+
* Remove the reservation from the Reserve queue.
47+
*
48+
* @method detachReservation
49+
* @memberof Scene_Base
50+
*/
2651
Scene_Base.prototype.detachReservation = function() {
2752
ImageManager.releaseReservation(this._imageReservationId);
2853
};
2954

55+
/**
56+
* Create the components and add them to the rendering process.
57+
*
58+
* @method create
59+
* @memberof Scene_Base
60+
*/
3061
Scene_Base.prototype.create = function() {
3162
};
3263

64+
/**
65+
* Returns wether the scene is active or not.
66+
*
67+
* @method isActive
68+
* @memberof Scene_Base
69+
* @return {Boolean} return true if the scene is active
70+
*/
3371
Scene_Base.prototype.isActive = function() {
3472
return this._active;
3573
};
3674

75+
/**
76+
* Return wether the scene is ready to start or not.
77+
*
78+
* @method isReady
79+
* @memberof Scene_Base
80+
* @return {Boolean} Return true if the scene is ready to start
81+
*/
3782
Scene_Base.prototype.isReady = function() {
3883
return ImageManager.isReady();
3984
};
4085

86+
/**
87+
* Start the scene processing.
88+
*
89+
* @method start
90+
* @memberof Scene_Base
91+
*/
4192
Scene_Base.prototype.start = function() {
4293
this._active = true;
4394
};
4495

96+
/**
97+
* Update the scene processing each new frame.
98+
*
99+
* @method update
100+
* @memberof Scene_Base
101+
*/
45102
Scene_Base.prototype.update = function() {
46103
this.updateFade();
47104
this.updateChildren();
105+
AudioManager.checkErrors();
48106
};
49107

108+
/**
109+
* Stop the scene processing.
110+
*
111+
* @method stop
112+
* @memberof Scene_Base
113+
*/
50114
Scene_Base.prototype.stop = function() {
51115
this._active = false;
52116
};
53117

118+
/**
119+
* Return wether the scene is busy or not.
120+
*
121+
* @method isBusy
122+
* @return {boolean} true if the scene is currently busy doing a fade
123+
*/
54124
Scene_Base.prototype.isBusy = function() {
55125
return this._fadeDuration > 0;
56126
};
57127

128+
/**
129+
* Terminate the scene before switching to a another scene.
130+
*
131+
* @method terminate
132+
* @memberof Scene_Base
133+
*/
58134
Scene_Base.prototype.terminate = function() {
59135
};
60136

137+
/**
138+
* Create the layer for the windows children
139+
* and add it to the rendering process.
140+
*
141+
* @method createWindowLayer
142+
* @memberof Scene_Base
143+
*/
61144
Scene_Base.prototype.createWindowLayer = function() {
62145
var width = Graphics.boxWidth;
63146
var height = Graphics.boxHeight;
@@ -68,24 +151,55 @@ Scene_Base.prototype.createWindowLayer = function() {
68151
this.addChild(this._windowLayer);
69152
};
70153

154+
/**
155+
* Add the children window to the windowLayer processing.
156+
*
157+
* @method addWindow
158+
* @memberof Scene_Base
159+
*/
71160
Scene_Base.prototype.addWindow = function(window) {
72161
this._windowLayer.addChild(window);
73162
};
74163

164+
/**
165+
* Request a fadeIn screen process.
166+
*
167+
* @method startFadeIn
168+
* @param {Number} [duration=30] The time the process will take for fadeIn the screen
169+
* @param {Boolean} [white=false] If true the fadein will be process with a white color else it's will be black
170+
*
171+
* @memberof Scene_Base
172+
*/
75173
Scene_Base.prototype.startFadeIn = function(duration, white) {
76174
this.createFadeSprite(white);
77175
this._fadeSign = 1;
78176
this._fadeDuration = duration || 30;
79177
this._fadeSprite.opacity = 255;
80178
};
81179

180+
/**
181+
* Request a fadeOut screen process.
182+
*
183+
* @method startFadeOut
184+
* @param {Number} [duration=30] The time the process will take for fadeOut the screen
185+
* @param {boolean} [white=false] If true the fadeOut will be process with a white color else it's will be black
186+
*
187+
* @memberof Scene_Base
188+
*/
82189
Scene_Base.prototype.startFadeOut = function(duration, white) {
83190
this.createFadeSprite(white);
84191
this._fadeSign = -1;
85192
this._fadeDuration = duration || 30;
86193
this._fadeSprite.opacity = 0;
87194
};
88195

196+
/**
197+
* Create a Screen sprite for the fadein and fadeOut purpose and
198+
* add it to the rendering process.
199+
*
200+
* @method createFadeSprite
201+
* @memberof Scene_Base
202+
*/
89203
Scene_Base.prototype.createFadeSprite = function(white) {
90204
if (!this._fadeSprite) {
91205
this._fadeSprite = new ScreenSprite();
@@ -98,6 +212,12 @@ Scene_Base.prototype.createFadeSprite = function(white) {
98212
}
99213
};
100214

215+
/**
216+
* Update the screen fade processing.
217+
*
218+
* @method updateFade
219+
* @memberof Scene_Base
220+
*/
101221
Scene_Base.prototype.updateFade = function() {
102222
if (this._fadeDuration > 0) {
103223
var d = this._fadeDuration;
@@ -110,6 +230,12 @@ Scene_Base.prototype.updateFade = function() {
110230
}
111231
};
112232

233+
/**
234+
* Update the children of the scene EACH frame.
235+
*
236+
* @method updateChildren
237+
* @memberof Scene_Base
238+
*/
113239
Scene_Base.prototype.updateChildren = function() {
114240
this.children.forEach(function(child) {
115241
if (child.update) {
@@ -118,16 +244,35 @@ Scene_Base.prototype.updateChildren = function() {
118244
});
119245
};
120246

247+
/**
248+
* Pop the scene from the stack array and switch to the
249+
* previous scene.
250+
*
251+
* @method popScene
252+
* @memberof Scene_Base
253+
*/
121254
Scene_Base.prototype.popScene = function() {
122255
SceneManager.pop();
123256
};
124257

258+
/**
259+
* Check wether the game should be triggering a gameover.
260+
*
261+
* @method checkGameover
262+
* @memberof Scene_Base
263+
*/
125264
Scene_Base.prototype.checkGameover = function() {
126265
if ($gameParty.isAllDead()) {
127266
SceneManager.goto(Scene_Gameover);
128267
}
129268
};
130269

270+
/**
271+
* Slowly fade out all the visual and audio of the scene.
272+
*
273+
* @method fadeOutAll
274+
* @memberof Scene_Base
275+
*/
131276
Scene_Base.prototype.fadeOutAll = function() {
132277
var time = this.slowFadeSpeed() / 60;
133278
AudioManager.fadeOutBgm(time);
@@ -136,10 +281,24 @@ Scene_Base.prototype.fadeOutAll = function() {
136281
this.startFadeOut(this.slowFadeSpeed());
137282
};
138283

284+
/**
285+
* Return the screen fade speed value.
286+
*
287+
* @method fadeSpeed
288+
* @memberof Scene_Base
289+
* @return {Number} Return the fade speed
290+
*/
139291
Scene_Base.prototype.fadeSpeed = function() {
140292
return 24;
141293
};
142294

295+
/**
296+
* Return a slow screen fade speed value.
297+
*
298+
* @method slowFadeSpeed
299+
* @memberof Scene_Base
300+
* @return {Number} Return the fade speed.
301+
*/
143302
Scene_Base.prototype.slowFadeSpeed = function() {
144303
return this.fadeSpeed() * 2;
145304
};

0 commit comments

Comments
 (0)