Scene_Game Flow - switch scene in one transition,

 Introduction 
This page is not suitable for beginners or who just want to finish making their StencylWorks as fast as possible. Not important for optimisation (for it is not done every frame) either but to switch scene without transition.   The snippet below shows a way to switch scene without transition in appearance. 
the snippet

code - found from preview code in design mode after added the snippet above to any event. 
switchScene(GameModel.get().scenes.get(0).getID(), null, createCrossfadeTransition(0));

code - without import com.stencyl.behavior.Script.*;
Script.switchScene(GameModel.get().scenes.get(0).getID(), null, createCrossfadeTransition(0));

code - shortcut, no transition. 
Engine.engine.switchScene(0,null,null); - switches to the first scene created in a stencylWorks project. 
Engine.engine.switchScene(1,null,null); - switches to the second scene created in a stencylWorks project. 
Engine.engine.switchScene(n-1,null,null); - switches to the nth scene created in a stencylWorks project. 

this snippet shares the same code function as relaod scene. 

To get the code for the transitions:
1. insert switch scene the with transitions in Main in Design mode,
2. click on preview code.  
3. find the code SwitchScene, 2nd and 3rd parameters. 
The same applies for reload scene. 

No comments:

Post a Comment