Difference between revisions of "ChangeScene (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "{| class="ts" style="width:100%" |- ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By |- | changeScene("s", t, d) || Definitio...") |
m |
||
| (7 intermediate revisions by the same user not shown) | |||
| Line 3: | Line 3: | ||
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By | ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By | ||
|- | |- | ||
| − | | changeScene(" | + | | changeScene("scn", typ, duration) || Definition || AFRLme |
|} | |} | ||
| − | + | <hr> | |
This small function allows you to change to another scene, define the scene transition effect & transition time. | This small function allows you to change to another scene, define the scene transition effect & transition time. | ||
| − | {| class="toccolours mw-collapsible mw-collapsed | + | {| class="toccolours mw-collapsible mw-collapsed ts" |
|- | |- | ||
! Transition Values | ! Transition Values | ||
|- | |- | ||
| − | | 0: no transition (immediate). | + | | [0] <span class="inlinecode">eFadeNo</span>: no transition (immediate). |
| + | |- | ||
| + | | [1] <span class="inlinecode">eFadeIn</span>: fade in. | ||
| + | |- | ||
| + | | [2] <span class="inlinecode">eFadeOut</span>: fade out. | ||
| + | |- | ||
| + | | [3] <span class="inlinecode">eFadeInAndOut</span>: fade in & out. | ||
|- | |- | ||
| − | | | + | | [4] <span class="inlinecode">eFadeToNew</span>: fade to new scene (blending). |
|- | |- | ||
| − | | | + | | [5] <span class="inlinecode">eShiftLeft</span>: wipe left. |
|- | |- | ||
| − | | | + | | [6] <span class="inlinecode">eShiftRight</span>: wipe right. |
|- | |- | ||
| − | | | + | | [7] <span class="inlinecode">eTunnelEffect</span>: tunnel fade in & out (circle). |
|- | |- | ||
| − | | | + | | [8] <span class="inlinecode">eFadeShader</span>: requires a shader to be linked via <span class="inlinecode">shaderSetOptions()</span>. |
|- | |- | ||
| − | | | + | | [9] <span class="inlinecode">eShiftUp</span>: wipe up. |
|- | |- | ||
| − | | | + | | [10] <span class="inlinecode">eShiftDown</span>: wipe down. |
|} | |} | ||
| + | <hr> | ||
| + | |||
== Instructions == | == Instructions == | ||
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/> | 1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/> | ||
2. To change the current scene... | 2. To change the current scene... | ||
| − | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
| − | changeScene("scene_name", | + | changeScene("scene_name", 3, 500) -- fade in/out over 500ms |
</syntaxhighlight> | </syntaxhighlight> | ||
| + | |||
== Main Script == | == Main Script == | ||
| − | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
| − | function changeScene( | + | function changeScene(scn, typ, duration, fe, fd) |
| − | fe = game | + | fe = game.FadeEffect -- store fade effect |
| + | fd = game.FadeDelay -- store fade delay | ||
-- + -- | -- + -- | ||
| − | + | game.FadeEffect = typ -- update fade effect to specified fade effect | |
| − | game | + | game.GameFadeDelay = duration -- update fade duration to specified fade duration |
-- + -- | -- + -- | ||
| − | game | + | game.CurrentScene = Scenes[scn] -- update scene |
-- + -- | -- + -- | ||
| − | + | setDelay(duration, function() -- delayed function which will be used to 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 | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| + | |||
== Syntax Breakdown == | == Syntax Breakdown == | ||
| Line 54: | Line 68: | ||
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | Description | ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:80%" | 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. |
| − | |} | + | |}{{toc}} |
Latest revision as of 14:45, 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
-- + --
game.FadeEffect = typ -- update fade effect to specified fade effect
game.GameFadeDelay = duration -- update fade duration to specified fade duration
-- + --
game.CurrentScene = Scenes[scn] -- update scene
-- + --
setDelay(duration, function() -- delayed function which will be used to 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. |