C# Класс 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
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
loadSceneOnBackgroundThread bool
onScreenObscured System.Action
previousSceneRender Microsoft.Xna.Framework.Graphics.RenderTarget2D
wantsPreviousSceneRender bool

Защищенные свойства (Protected)

Свойство Тип Описание
_isNewSceneLoaded bool
sceneLoadAction Func

Private Properties

Свойство Тип Описание

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
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

Описание методов

SceneTransition() защищенный Метод

protected SceneTransition ( Func sceneLoadAction, bool wantsPreviousSceneRender = true ) : System
sceneLoadAction Func
wantsPreviousSceneRender bool
Результат System

SceneTransition() защищенный Метод

protected SceneTransition ( bool wantsPreviousSceneRender = true ) : System
wantsPreviousSceneRender bool
Результат System

loadNextScene() защищенный Метод

protected loadNextScene ( ) : IEnumerator
Результат IEnumerator

onBeginTransition() публичный Метод

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
Результат IEnumerator

preRender() публичный Метод

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.
Результат void

render() публичный Метод

do all of your rendering here
public render ( Graphics graphics ) : void
graphics Graphics Graphics.
Результат void

tickEffectProgressProperty() публичный Метод

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
Результат IEnumerator

transitionComplete() защищенный Метод

this should be called when your transition is complete and the new Scene has been set. It will clean up
protected transitionComplete ( ) : void
Результат void

Описание свойств

_isNewSceneLoaded защищенное свойство

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
Результат bool

loadSceneOnBackgroundThread публичное свойство

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
Результат bool

onScreenObscured публичное свойство

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
Результат System.Action

previousSceneRender публичное свойство

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
Результат Microsoft.Xna.Framework.Graphics.RenderTarget2D

sceneLoadAction защищенное свойство

function that should return the newly loaded scene
protected Func sceneLoadAction
Результат Func

wantsPreviousSceneRender публичное свойство

if true, Nez will render the previous scene into previousSceneRender so that you can use it with your transition
public bool wantsPreviousSceneRender
Результат bool