@@ -45,7 +45,7 @@ var Systems = function (state, config)
4545 this . stateManager ;
4646 this . time ;
4747 this . tweens ;
48- // this.updates;
48+ this . updates ;
4949
5050 // State properties
5151 this . children ;
@@ -83,7 +83,7 @@ Systems.prototype = {
8383 this . stateManager = new StateManager ( this . state , game ) ;
8484 this . time = new Clock ( this . state ) ;
8585 this . tweens = new TweenManager ( this . state ) ;
86- // this.updates = new UpdateManager(this.state);
86+ this . updates = new UpdateManager ( this . state ) ;
8787
8888 this . inject ( ) ;
8989 } ,
@@ -163,7 +163,10 @@ Systems.prototype = {
163163
164164 this . settings . active = false ;
165165
166- // Notify the State callback or dispatch an event
166+ if ( this . state . pause )
167+ {
168+ this . state . pause . call ( this . state ) ;
169+ }
167170 } ,
168171
169172 resume : function ( )
@@ -172,7 +175,10 @@ Systems.prototype = {
172175
173176 this . settings . active = true ;
174177
175- // Notify the State callback or dispatch an event
178+ if ( this . state . resume )
179+ {
180+ this . state . resume . call ( this . state ) ;
181+ }
176182 } ,
177183
178184 sleep : function ( )
@@ -182,7 +188,10 @@ Systems.prototype = {
182188 this . settings . active = false ;
183189 this . settings . visible = false ;
184190
185- // Notify the State callback or dispatch an event
191+ if ( this . state . sleep )
192+ {
193+ this . state . sleep . call ( this . state ) ;
194+ }
186195 } ,
187196
188197 wake : function ( )
@@ -192,14 +201,28 @@ Systems.prototype = {
192201 this . settings . active = true ;
193202 this . settings . visible = true ;
194203
195- // Notify the State callback or dispatch an event
204+ if ( this . state . wake )
205+ {
206+ this . state . wake . call ( this . state ) ;
207+ }
208+ } ,
209+
210+ start : function ( data )
211+ {
212+ // Was started by the GlobalStateManager
213+
214+ this . settings . data = data ;
215+
216+ this . settings . active = true ;
217+ this . settings . visible = true ;
196218 } ,
197219
198220 shutdown : function ( )
199221 {
200222 // Was stopped by the GlobalStateManager
201223
202224 this . settings . active = false ;
225+ this . settings . visible = false ;
203226
204227 // If all State level managers followed the same pattern then we could just iterate
205228 // the map and call shutdown on all of them, same for destroy
@@ -212,7 +235,10 @@ Systems.prototype = {
212235 this . time . shutdown ( ) ;
213236 this . tweens . shutdown ( ) ;
214237
215- this . state . shutdown . call ( this . state ) ;
238+ if ( this . state . shutdown )
239+ {
240+ this . state . shutdown . call ( this . state ) ;
241+ }
216242 } ,
217243
218244 // Game level nuke
@@ -224,6 +250,10 @@ Systems.prototype = {
224250 this . tweens . destroy ( ) ;
225251
226252 // etc
253+ if ( this . state . destroy )
254+ {
255+ this . state . destroy . call ( this . state ) ;
256+ }
227257 }
228258} ;
229259
0 commit comments