Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » GABehaviorFadeOverCanvas
Game application behavior adding a fade-over-canvas overlay to the desktop. The overlay fades a canvas in, keeps it shown and fades it out again. The canvas is created using a Canvas Creators. Typically this is a single color, like black or white, but it can be also an image, video or a complex canvas. Canvas creates can be loaded from file but it is easier to define a Widget Designer through XML Gui Theming to fetch the canvas creator from. The overlay can be controlled through actions and conditions of the GABehaviorStateMachine.
To access this behavior from other application behaviors use GABehaviorFadeOverCanvas.getBehaviorInApp().
This behavior adds these state machine actions.
Set overlay parameters.
| Parameter | Value | Description |
|---|---|---|
| time.fadeIn | float | Duration in seconds of fading in. Default value is 1. |
| time.stay | float | Duration in seconds the canvas stays shown before fading out. Default value is 1. To manually fade out set this value high, for example 9999. |
| time.fadeOut | float | Duration in seconds of fading out. Default value is 1. |
| smoothStep | true, false | Use smooth stepping for fading instead of linear stepping. Default is true. |
| canvasCreator | string | Path to canvas creator file (.decc) to load and use. |
| designerSelector | string | Gui theme designer selector to use. Uses the normal.canvas property as canvas creator. |
| designerSelector.preset | black, white | Use designer selector with predefined name:
|
This is an example of using this action to fade over a white canvas:
<action name='fadeOverCanvas.set'> <parameter name='designerSelector.preset'>white</parameter> <parameter name='time.fadeIn'>0.5</parameter> <parameter name='time.stay'>2</parameter> <parameter name='time.fadeOut'>0.5</parameter> </action>
Update overlay parameters and run overlay actions.
| Parameter | Value | Description |
|---|---|---|
| set | hidden, shown | Set overlay state directly. |
| fade | in, out | Start fading in/out. Has no effect if overlay is not in the hidden state (fade in) or shown state (fade out). |
This is an example of using this action to start fading in:
<action name='fadeOverCanvas.update'> <parameter name='fade'>in</parameter> </action>
This is an example of using this action to set overlay shown then start fading out:
<action name='fadeOverCanvas.update'> <parameter name='set'>shown</parameter> <parameter name='fade'>out</parameter> </action>
This behavior adds these state machine conditions.
Evaluate overlay parameters.
| Parameter | Value | Description |
|---|---|---|
| running | true, false | Overlay is running. Equals to state is not hidden. |
| state | hidden, fadeIn, shown, fadeOut | Overlay state equals value. |
| state.not | hidden, fadeIn, shown, fadeOut | Overlay state does not equal value. |
This is an example of using this condition to check that the overlay is not hidden:
<action name='myAction'> <condition>fadeOverCanvas.check</condition> <parameter name='state.not'>hidden</parameter> </action>
This behavior sends these state machine events.
Overlay is now hidden. Happens if fading out finished or the overlay has been set to hidden.
Overlay begins fading in.
Overlay is now shown. Happens if fading in finished or the overlay has been set to shown.
Overlay begins fading out.
This behavior requires no other behaviors.
Since DragonScript Module Version 1.35