C# Class Nez.SceneTransition

SceneTransition is used to transition from one Scene to another or within a scene with an effect. If sceneLoadAction is null Nez will perform an in-Scene transition as opposed to loading a new Scene mid transition. The general gist of a transition is the following: - onBeginTransition will be called allowing you to yield for multipart transitions - for two part transitions with Effects you can yield on a call to tickEffectProgressProperty for part one to obscure the screen - next, yield a call to loadNextScene to load up the new Scene - finally, yield again on tickEffectProgressProperty to un-obscure the screen and show the new Scene
Mostra file Open project: prime31/Nez Class Usage Examples

Public Properties

Property Type Description
loadSceneOnBackgroundThread bool
onScreenObscured System.Action
previousSceneRender Microsoft.Xna.Framework.Graphics.RenderTarget2D
wantsPreviousSceneRender bool

Protected Properties

Property Type Description
_isNewSceneLoaded bool
sceneLoadAction Func

Private Properties

Property Type Description

Public Methods

Method Description
onBeginTransition ( ) : IEnumerator

called after the previousSceneRender occurs for the first (and only) time. At this point you can load your new Scene after yielding one frame (so the first render call happens before scene loading).

preRender ( Graphics graphics ) : void

called before the Scene is rendered. This allows a transition to render to a RenderTarget if needed and avoids issues with MonoGame clearing the framebuffer when a RenderTarget is used.

render ( Graphics graphics ) : void

do all of your rendering here

tickEffectProgressProperty ( Effect effect, float duration, EaseType easeType = EaseType.ExpoOut, bool reverseDirection = false ) : IEnumerator

the most common type of transition seems to be one that ticks progress from 0 - 1. This method takes care of that for you if your transition needs to have a _progress property ticked after the scene loads.

Protected Methods

Method Description
SceneTransition ( Func sceneLoadAction, bool wantsPreviousSceneRender = true ) : System
SceneTransition ( bool wantsPreviousSceneRender = true ) : System
loadNextScene ( ) : IEnumerator
transitionComplete ( ) : void

this should be called when your transition is complete and the new Scene has been set. It will clean up

Method Details

SceneTransition() protected method

protected SceneTransition ( Func sceneLoadAction, bool wantsPreviousSceneRender = true ) : System
sceneLoadAction Func
wantsPreviousSceneRender bool
return System

SceneTransition() protected method

protected SceneTransition ( bool wantsPreviousSceneRender = true ) : System
wantsPreviousSceneRender bool
return System

loadNextScene() protected method

protected loadNextScene ( ) : IEnumerator
return IEnumerator

onBeginTransition() public method

called after the previousSceneRender occurs for the first (and only) time. At this point you can load your new Scene after yielding one frame (so the first render call happens before scene loading).
public onBeginTransition ( ) : IEnumerator
return IEnumerator

preRender() public method

called before the Scene is rendered. This allows a transition to render to a RenderTarget if needed and avoids issues with MonoGame clearing the framebuffer when a RenderTarget is used.
public preRender ( Graphics graphics ) : void
graphics Graphics Graphics.
return void

render() public method

do all of your rendering here
public render ( Graphics graphics ) : void
graphics Graphics Graphics.
return void

tickEffectProgressProperty() public method

the most common type of transition seems to be one that ticks progress from 0 - 1. This method takes care of that for you if your transition needs to have a _progress property ticked after the scene loads.
public tickEffectProgressProperty ( Effect effect, float duration, EaseType easeType = EaseType.ExpoOut, bool reverseDirection = false ) : IEnumerator
effect Microsoft.Xna.Framework.Graphics.Effect
duration float duration
easeType EaseType
reverseDirection bool if true, _progress will go from 1 to 0. If false, it goes form 0 to 1
return IEnumerator

transitionComplete() protected method

this should be called when your transition is complete and the new Scene has been set. It will clean up
protected transitionComplete ( ) : void
return void

Property Details

_isNewSceneLoaded protected_oe property

use this for two part transitions. For example, a fade would fade to black first then when _isNewSceneLoaded becomes true it would fade in. For in-Scene transitions _isNewSceneLoaded will be set to true at the midpoint just as if a new Scene was loaded.
protected bool _isNewSceneLoaded
return bool

loadSceneOnBackgroundThread public_oe property

if true, the next Scene will be loaded on a background thread. Note that if raw PNG files are used they cannot be loaded on a background thread.
public bool loadSceneOnBackgroundThread
return bool

onScreenObscured public_oe property

called when loadNextScene is executing. This is useful when doing inter-Scene transitions so that you know when you can more the Camera or reset any Entities
public Action,System onScreenObscured
return System.Action

previousSceneRender public_oe property

contains the last render of the previous Scene. Can be used to obscure the screen while loading a new Scene.
public RenderTarget2D,Microsoft.Xna.Framework.Graphics previousSceneRender
return Microsoft.Xna.Framework.Graphics.RenderTarget2D

sceneLoadAction protected_oe property

function that should return the newly loaded scene
protected Func sceneLoadAction
return Func

wantsPreviousSceneRender public_oe property

if true, Nez will render the previous scene into previousSceneRender so that you can use it with your transition
public bool wantsPreviousSceneRender
return bool