1
- //-----------------------------------------------------------------------------
2
- // Scene_Base
3
- //
4
- // The superclass of all scenes within the game.
1
+ //=============================================================================
5
2
3
+ /**
4
+ * The Superclass of all scene within the game.
5
+ *
6
+ * @class Scene_Base
7
+ * @constructor
8
+ * @extends Stage
9
+ */
6
10
function Scene_Base ( ) {
7
11
this . initialize . apply ( this , arguments ) ;
8
12
}
9
13
10
14
Scene_Base . prototype = Object . create ( Stage . prototype ) ;
11
15
Scene_Base . prototype . constructor = Scene_Base ;
12
16
17
+
18
+ /**
19
+ * Create a instance of Scene_Base.
20
+ *
21
+ * @instance
22
+ * @memberof Scene_Base
23
+ */
13
24
Scene_Base . prototype . initialize = function ( ) {
14
25
Stage . prototype . initialize . call ( this ) ;
15
26
this . _active = false ;
@@ -19,45 +30,127 @@ Scene_Base.prototype.initialize = function() {
19
30
this . _imageReservationId = Utils . generateRuntimeId ( ) ;
20
31
} ;
21
32
33
+ /**
34
+ * Attach a reservation to the reserve queue.
35
+ *
36
+ * @method attachReservation
37
+ * @instance
38
+ * @memberof Scene_Base
39
+ */
22
40
Scene_Base . prototype . attachReservation = function ( ) {
23
41
ImageManager . setDefaultReservationId ( this . _imageReservationId ) ;
24
42
} ;
25
43
44
+ /**
45
+ * Remove the reservation from the Reserve queue.
46
+ *
47
+ * @method detachReservation
48
+ * @instance
49
+ * @memberof Scene_Base
50
+ */
26
51
Scene_Base . prototype . detachReservation = function ( ) {
27
52
ImageManager . releaseReservation ( this . _imageReservationId ) ;
28
53
} ;
29
54
55
+ /**
56
+ * Create the components and add them to the rendering process.
57
+ *
58
+ * @method create
59
+ * @instance
60
+ * @memberof Scene_Base
61
+ */
30
62
Scene_Base . prototype . create = function ( ) {
31
63
} ;
32
64
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
+ */
33
73
Scene_Base . prototype . isActive = function ( ) {
34
74
return this . _active ;
35
75
} ;
36
76
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
+ */
37
85
Scene_Base . prototype . isReady = function ( ) {
38
86
return ImageManager . isReady ( ) ;
39
87
} ;
40
88
89
+ /**
90
+ * Start the scene processing.
91
+ *
92
+ * @method start
93
+ * @instance
94
+ * @memberof Scene_Base
95
+ */
41
96
Scene_Base . prototype . start = function ( ) {
42
97
this . _active = true ;
43
98
} ;
44
99
100
+ /**
101
+ * Update the scene processing each new frame.
102
+ *
103
+ * @method update
104
+ * @instance
105
+ * @memberof Scene_Base
106
+ */
45
107
Scene_Base . prototype . update = function ( ) {
46
108
this . updateFade ( ) ;
47
109
this . updateChildren ( ) ;
48
110
} ;
49
111
112
+ /**
113
+ * Stop the scene processing.
114
+ *
115
+ * @method stop
116
+ * @instance
117
+ * @memberof Scene_Base
118
+ */
50
119
Scene_Base . prototype . stop = function ( ) {
51
120
this . _active = false ;
52
121
} ;
53
122
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
+ */
54
132
Scene_Base . prototype . isBusy = function ( ) {
55
133
return this . _fadeDuration > 0 ;
56
134
} ;
57
135
136
+ /**
137
+ * Terminate the scene before switching to a another scene.
138
+ *
139
+ * @method terminate
140
+ * @instance
141
+ * @memberof Scene_Base
142
+ */
58
143
Scene_Base . prototype . terminate = function ( ) {
59
144
} ;
60
145
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
+ */
61
154
Scene_Base . prototype . createWindowLayer = function ( ) {
62
155
var width = Graphics . boxWidth ;
63
156
var height = Graphics . boxHeight ;
@@ -68,24 +161,59 @@ Scene_Base.prototype.createWindowLayer = function() {
68
161
this . addChild ( this . _windowLayer ) ;
69
162
} ;
70
163
164
+ /**
165
+ * Add the children window to the windowLayer processing.
166
+ *
167
+ * @method addWindow
168
+ * @instance
169
+ * @memberof Scene_Base
170
+ */
71
171
Scene_Base . prototype . addWindow = function ( window ) {
72
172
this . _windowLayer . addChild ( window ) ;
73
173
} ;
74
174
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
+ */
75
185
Scene_Base . prototype . startFadeIn = function ( duration , white ) {
76
186
this . createFadeSprite ( white ) ;
77
187
this . _fadeSign = 1 ;
78
188
this . _fadeDuration = duration || 30 ;
79
189
this . _fadeSprite . opacity = 255 ;
80
190
} ;
81
191
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
+ */
82
202
Scene_Base . prototype . startFadeOut = function ( duration , white ) {
83
203
this . createFadeSprite ( white ) ;
84
204
this . _fadeSign = - 1 ;
85
205
this . _fadeDuration = duration || 30 ;
86
206
this . _fadeSprite . opacity = 0 ;
87
207
} ;
88
208
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
+ */
89
217
Scene_Base . prototype . createFadeSprite = function ( white ) {
90
218
if ( ! this . _fadeSprite ) {
91
219
this . _fadeSprite = new ScreenSprite ( ) ;
@@ -98,6 +226,13 @@ Scene_Base.prototype.createFadeSprite = function(white) {
98
226
}
99
227
} ;
100
228
229
+ /**
230
+ * Update the screen fade processing.
231
+ *
232
+ * @method updateFade
233
+ * @instance
234
+ * @memberof Scene_Base
235
+ */
101
236
Scene_Base . prototype . updateFade = function ( ) {
102
237
if ( this . _fadeDuration > 0 ) {
103
238
var d = this . _fadeDuration ;
@@ -110,6 +245,13 @@ Scene_Base.prototype.updateFade = function() {
110
245
}
111
246
} ;
112
247
248
+ /**
249
+ * Update the children of the scene EACH frame.
250
+ *
251
+ * @method updateChildren
252
+ * @instance
253
+ * @memberof Scene_Base
254
+ */
113
255
Scene_Base . prototype . updateChildren = function ( ) {
114
256
this . children . forEach ( function ( child ) {
115
257
if ( child . update ) {
@@ -118,16 +260,38 @@ Scene_Base.prototype.updateChildren = function() {
118
260
} ) ;
119
261
} ;
120
262
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
+ */
121
271
Scene_Base . prototype . popScene = function ( ) {
122
272
SceneManager . pop ( ) ;
123
273
} ;
124
274
275
+ /**
276
+ * Check whether the game should be triggering a gameover.
277
+ *
278
+ * @method checkGameover
279
+ * @instance
280
+ * @memberof Scene_Base
281
+ */
125
282
Scene_Base . prototype . checkGameover = function ( ) {
126
283
if ( $gameParty . isAllDead ( ) ) {
127
284
SceneManager . goto ( Scene_Gameover ) ;
128
285
}
129
286
} ;
130
287
288
+ /**
289
+ * Slowly fade out all the visual and audio of the scene.
290
+ *
291
+ * @method fadeOutAll
292
+ * @instance
293
+ * @memberof Scene_Base
294
+ */
131
295
Scene_Base . prototype . fadeOutAll = function ( ) {
132
296
var time = this . slowFadeSpeed ( ) / 60 ;
133
297
AudioManager . fadeOutBgm ( time ) ;
@@ -136,10 +300,26 @@ Scene_Base.prototype.fadeOutAll = function() {
136
300
this . startFadeOut ( this . slowFadeSpeed ( ) ) ;
137
301
} ;
138
302
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
+ */
139
311
Scene_Base . prototype . fadeSpeed = function ( ) {
140
312
return 24 ;
141
313
} ;
142
314
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
+ */
143
323
Scene_Base . prototype . slowFadeSpeed = function ( ) {
144
324
return this . fadeSpeed ( ) * 2 ;
145
325
} ;
0 commit comments