Difference between revisions of "ChangeScene (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m
m
Line 71: Line 71:
 
| "scn" || "string" || This should be a "string" value containing the name of the scene you want to change to.
 
| "scn" || "string" || This should be a "string" value containing the name of the scene you want to change to.
 
|-
 
|-
| typ || integer || This should be an integer value between 0 & 10 or the variable name equivalent, which will be used to determine the transition effect.
+
| typ || integer || This should be an integer value between 0 & 10 or the variable name equivalent which will be used to determine the transition effect.
 
|-
 
|-
 
| duration || integer || This should be an integer value containing the transition time between scenes in milliseconds.
 
| duration || integer || This should be an integer value containing the transition time between scenes in milliseconds.
 
|}{{toc}}
 
|}{{toc}}

Revision as of 14:43, 23 August 2022

Name Type By
changeScene("scn", typ, duration) Definition AFRLme

This small function allows you to change to another scene, define the scene transition effect & transition time.

Transition Values
[0] eFadeNo: no transition (immediate).
[1] eFadeIn: fade in.
[2] eFadeOut: fade out.
[3] eFadeInAndOut: fade in & out.
[4] eFadeToNew: fade to new scene (blending).
[5] eShiftLeft: wipe left.
[6] eShiftRight: wipe right.
[7] eTunnelEffect: tunnel fade in & out (circle).
[8] eFadeShader: requires a shader to be linked via shaderSetOptions().
[9] eShiftUp: wipe up.
[10] eShiftDown: wipe down.


Instructions

1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2. To change the current scene...

changeScene("scene_name", 3, 500) -- fade in/out over 500ms


Main Script

function changeScene(scn, typ, duration, fe, fd)
 fe = game.FadeEffect -- store fade effect
 fd = game.FadeDelay -- store fade delay
 -- + --
 if typ < 0 then typ = 0 elseif typ > 10 then typ = 10 end -- fallback in case fade effect is less than 0 or more than 10
 game.FadeEffect = typ -- update fade effect to specified fade effect
 game.GameFadeDelay = duration -- update fade duration to specified fade duration
 -- + --
 game.CurrentScene = Scenes[scn]
 -- + --
 setDelay(duration, function() -- restore previous scene effects
   game.FadeEffect = fe -- restore fade effect back to stored fade effect
   game.FadeDelay = fd -- restore fade duration back to stored fade duration
 end)
end


Syntax Breakdown

Name Type Description
"scn" "string" This should be a "string" value containing the name of the scene you want to change to.
typ integer This should be an integer value between 0 & 10 or the variable name equivalent which will be used to determine the transition effect.
duration integer This should be an integer value containing the transition time between scenes in milliseconds.