User Tools

Site Tools


dragengine:modules:dragonscript:gabehavior_fadeovercanvas

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().

State Machine Actions

This behavior adds these state machine actions.

fadeOverCanvas.set

Set overlay parameters.

ParameterValueDescription
time.fadeInfloatDuration in seconds of fading in. Default value is 1.
time.stayfloatDuration 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.fadeOutfloatDuration in seconds of fading out. Default value is 1.
smoothSteptrue, falseUse smooth stepping for fading instead of linear stepping. Default is true.
canvasCreatorstringPath to canvas creator file (.decc) to load and use.
designerSelectorstringGui theme designer selector to use. Uses the normal.canvas property as canvas creator.
designerSelector.presetblack, white

Use designer selector with predefined name:

  • black: FadeOverCanvas.Black
  • white: FadeOverCanvas.White

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>

fadeOverCanvas.update

Update overlay parameters and run overlay actions.

ParameterValueDescription
sethidden, shownSet overlay state directly.
fadein, outStart 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>

State Machine Conditions

This behavior adds these state machine conditions.

fadeOverCanvas.check

Evaluate overlay parameters.

ParameterValueDescription
runningtrue, falseOverlay is running. Equals to state is not hidden.
statehidden, fadeIn, shown, fadeOutOverlay state equals value.
state.nothidden, fadeIn, shown, fadeOutOverlay 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>

State Machine Events

This behavior sends these state machine events.

fadeOverCanvas.hidden

Overlay is now hidden. Happens if fading out finished or the overlay has been set to hidden.

fadeOverCanvas.fadeIn

Overlay begins fading in.

fadeOverCanvas.shown

Overlay is now shown. Happens if fading in finished or the overlay has been set to shown.

fadeOverCanvas.fadeOut

Overlay begins fading out.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

API Documentation

GABehaviorFadeOverCanvas.

Since DragonScript Module Version 1.35

Use Cases

  • Fade over black from one scene to another.
  • Create effects like flash-bang temporarily whiteout the screen.

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/gabehavior_fadeovercanvas.txt · Last modified: by dragonlord