Skip to content

Commit c62f214

Browse files
authored
Merge pull request #90 from niokasgami/patch-4
Added docs to Scene_Base
2 parents fd69b0c + 9865abc commit c62f214

File tree

1 file changed

+184
-4
lines changed

1 file changed

+184
-4
lines changed

js/rpg_scenes/Scene_Base.js

Lines changed: 184 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
//-----------------------------------------------------------------------------
2-
// Scene_Base
3-
//
4-
// The superclass of all scenes within the game.
1+
//=============================================================================
52

3+
/**
4+
* The Superclass of all scene within the game.
5+
*
6+
* @class Scene_Base
7+
* @constructor
8+
* @extends Stage
9+
*/
610
function Scene_Base() {
711
this.initialize.apply(this, arguments);
812
}
913

1014
Scene_Base.prototype = Object.create(Stage.prototype);
1115
Scene_Base.prototype.constructor = Scene_Base;
1216

17+
18+
/**
19+
* Create a instance of Scene_Base.
20+
*
21+
* @instance
22+
* @memberof Scene_Base
23+
*/
1324
Scene_Base.prototype.initialize = function() {
1425
Stage.prototype.initialize.call(this);
1526
this._active = false;
@@ -19,45 +30,127 @@ Scene_Base.prototype.initialize = function() {
1930
this._imageReservationId = Utils.generateRuntimeId();
2031
};
2132

33+
/**
34+
* Attach a reservation to the reserve queue.
35+
*
36+
* @method attachReservation
37+
* @instance
38+
* @memberof Scene_Base
39+
*/
2240
Scene_Base.prototype.attachReservation = function() {
2341
ImageManager.setDefaultReservationId(this._imageReservationId);
2442
};
2543

44+
/**
45+
* Remove the reservation from the Reserve queue.
46+
*
47+
* @method detachReservation
48+
* @instance
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+
* @instance
60+
* @memberof Scene_Base
61+
*/
3062
Scene_Base.prototype.create = function() {
3163
};
3264

65+
/**
66+
* Returns whether the scene is active or not.
67+
*
68+
* @method isActive
69+
* @instance
70+
* @memberof Scene_Base
71+
* @return {Boolean} return true if the scene is active
72+
*/
3373
Scene_Base.prototype.isActive = function() {
3474
return this._active;
3575
};
3676

77+
/**
78+
* Return whether the scene is ready to start or not.
79+
*
80+
* @method isReady
81+
* @instance
82+
* @memberof Scene_Base
83+
* @return {Boolean} Return true if the scene is ready to start
84+
*/
3785
Scene_Base.prototype.isReady = function() {
3886
return ImageManager.isReady();
3987
};
4088

89+
/**
90+
* Start the scene processing.
91+
*
92+
* @method start
93+
* @instance
94+
* @memberof Scene_Base
95+
*/
4196
Scene_Base.prototype.start = function() {
4297
this._active = true;
4398
};
4499

100+
/**
101+
* Update the scene processing each new frame.
102+
*
103+
* @method update
104+
* @instance
105+
* @memberof Scene_Base
106+
*/
45107
Scene_Base.prototype.update = function() {
46108
this.updateFade();
47109
this.updateChildren();
48110
};
49111

112+
/**
113+
* Stop the scene processing.
114+
*
115+
* @method stop
116+
* @instance
117+
* @memberof Scene_Base
118+
*/
50119
Scene_Base.prototype.stop = function() {
51120
this._active = false;
52121
};
53122

123+
124+
/**
125+
* Return whether the scene is busy or not.
126+
*
127+
* @method isBusy
128+
* @instance
129+
* @memberof Scene_Base
130+
* @return {Boolean} Return true if the scene is currently busy
131+
*/
54132
Scene_Base.prototype.isBusy = function() {
55133
return this._fadeDuration > 0;
56134
};
57135

136+
/**
137+
* Terminate the scene before switching to a another scene.
138+
*
139+
* @method terminate
140+
* @instance
141+
* @memberof Scene_Base
142+
*/
58143
Scene_Base.prototype.terminate = function() {
59144
};
60145

146+
/**
147+
* Create the layer for the windows children
148+
* and add it to the rendering process.
149+
*
150+
* @method createWindowLayer
151+
* @instance
152+
* @memberof Scene_Base
153+
*/
61154
Scene_Base.prototype.createWindowLayer = function() {
62155
var width = Graphics.boxWidth;
63156
var height = Graphics.boxHeight;
@@ -68,24 +161,59 @@ Scene_Base.prototype.createWindowLayer = function() {
68161
this.addChild(this._windowLayer);
69162
};
70163

164+
/**
165+
* Add the children window to the windowLayer processing.
166+
*
167+
* @method addWindow
168+
* @instance
169+
* @memberof Scene_Base
170+
*/
71171
Scene_Base.prototype.addWindow = function(window) {
72172
this._windowLayer.addChild(window);
73173
};
74174

175+
/**
176+
* Request a fadeIn screen process.
177+
*
178+
* @method startFadeIn
179+
* @param {Number} [duration=30] The time the process will take for fadeIn the screen
180+
* @param {Boolean} [white=false] If true the fadein will be process with a white color else it's will be black
181+
*
182+
* @instance
183+
* @memberof Scene_Base
184+
*/
75185
Scene_Base.prototype.startFadeIn = function(duration, white) {
76186
this.createFadeSprite(white);
77187
this._fadeSign = 1;
78188
this._fadeDuration = duration || 30;
79189
this._fadeSprite.opacity = 255;
80190
};
81191

192+
/**
193+
* Request a fadeOut screen process.
194+
*
195+
* @method startFadeOut
196+
* @param {Number} [duration=30] The time the process will take for fadeOut the screen
197+
* @param {Boolean} [white=false] If true the fadeOut will be process with a white color else it's will be black
198+
*
199+
* @instance
200+
* @memberof Scene_Base
201+
*/
82202
Scene_Base.prototype.startFadeOut = function(duration, white) {
83203
this.createFadeSprite(white);
84204
this._fadeSign = -1;
85205
this._fadeDuration = duration || 30;
86206
this._fadeSprite.opacity = 0;
87207
};
88208

209+
/**
210+
* Create a Screen sprite for the fadein and fadeOut purpose and
211+
* add it to the rendering process.
212+
*
213+
* @method createFadeSprite
214+
* @instance
215+
* @memberof Scene_Base
216+
*/
89217
Scene_Base.prototype.createFadeSprite = function(white) {
90218
if (!this._fadeSprite) {
91219
this._fadeSprite = new ScreenSprite();
@@ -98,6 +226,13 @@ Scene_Base.prototype.createFadeSprite = function(white) {
98226
}
99227
};
100228

229+
/**
230+
* Update the screen fade processing.
231+
*
232+
* @method updateFade
233+
* @instance
234+
* @memberof Scene_Base
235+
*/
101236
Scene_Base.prototype.updateFade = function() {
102237
if (this._fadeDuration > 0) {
103238
var d = this._fadeDuration;
@@ -110,6 +245,13 @@ Scene_Base.prototype.updateFade = function() {
110245
}
111246
};
112247

248+
/**
249+
* Update the children of the scene EACH frame.
250+
*
251+
* @method updateChildren
252+
* @instance
253+
* @memberof Scene_Base
254+
*/
113255
Scene_Base.prototype.updateChildren = function() {
114256
this.children.forEach(function(child) {
115257
if (child.update) {
@@ -118,16 +260,38 @@ Scene_Base.prototype.updateChildren = function() {
118260
});
119261
};
120262

263+
/**
264+
* Pop the scene from the stack array and switch to the
265+
* previous scene.
266+
*
267+
* @method popScene
268+
* @instance
269+
* @memberof Scene_Base
270+
*/
121271
Scene_Base.prototype.popScene = function() {
122272
SceneManager.pop();
123273
};
124274

275+
/**
276+
* Check whether the game should be triggering a gameover.
277+
*
278+
* @method checkGameover
279+
* @instance
280+
* @memberof Scene_Base
281+
*/
125282
Scene_Base.prototype.checkGameover = function() {
126283
if ($gameParty.isAllDead()) {
127284
SceneManager.goto(Scene_Gameover);
128285
}
129286
};
130287

288+
/**
289+
* Slowly fade out all the visual and audio of the scene.
290+
*
291+
* @method fadeOutAll
292+
* @instance
293+
* @memberof Scene_Base
294+
*/
131295
Scene_Base.prototype.fadeOutAll = function() {
132296
var time = this.slowFadeSpeed() / 60;
133297
AudioManager.fadeOutBgm(time);
@@ -136,10 +300,26 @@ Scene_Base.prototype.fadeOutAll = function() {
136300
this.startFadeOut(this.slowFadeSpeed());
137301
};
138302

303+
/**
304+
* Return the screen fade speed value.
305+
*
306+
* @method fadeSpeed
307+
* @instance
308+
* @memberof Scene_Base
309+
* @return {Number} Return the fade speed
310+
*/
139311
Scene_Base.prototype.fadeSpeed = function() {
140312
return 24;
141313
};
142314

315+
/**
316+
* Return a slow screen fade speed value.
317+
*
318+
* @method slowFadeSpeed
319+
* @instance
320+
* @memberof Scene_Base
321+
* @return {Number} Return the fade speed
322+
*/
143323
Scene_Base.prototype.slowFadeSpeed = function() {
144324
return this.fadeSpeed() * 2;
145325
};

0 commit comments

Comments
 (0)