Scene

abstract class Scene : InjectorDependency, ViewsContainer, CoroutineScope, ResourcesContainer, Extra

Acts as a controller. Subclasses must override at least one of: sceneInit or sceneMain.

The lifecycle of the Scene for (SceneContainer.pushTo, SceneContainer.changeTo, SceneContainer.back, SceneContainer.forward):

  • OLD Scene -> NEW Scene -- Scene is changed

  • NEW: sceneInit - BLOCK - Called when this scene enters. Waits until completed

  • NEW: sceneMain - DO NOT BLOCK - Called after sceneInit. Doesn't wait for completion. Its underlying Job is closed automatically on sceneAfterDestroy

  • OLD: sceneBeforeLeaving - BLOCK - Called on the old scene. Waits until completed.

  • Transition from the old view and the new view is performed the animation transition set values for View.ratio in the SceneContainer.transitionView in the range 0..1

  • OLD: sceneDestroy - BLOCK - Called when this scene exits. Waits until completed.

  • OLD: sceneAfterDestroy - DO NOT BLOCK - Cancels the Job of the old scene. Do not wait

  • NEW: sceneAfterInit - DO NOT BLOCK - Similar to sceneMain but after the transition.

  • New scene is returned

Inheritors

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val ag: AG

A reference to the AG from the Views

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override var extra: ExtraType
Link copied to clipboard
Link copied to clipboard
lateinit var injector: Injector

A child Injector for this instance. Set by the init method.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val resources: Resources
Link copied to clipboard

The ResourcesRoot singleton. Set by the init method.

Link copied to clipboard
Link copied to clipboard

The SceneContainer that contains this Scene. Set by the init method.

Link copied to clipboard
open val sceneHeight: Int
Link copied to clipboard
Link copied to clipboard
open val sceneWidth: Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open lateinit override var views: Views

The Views singleton of the application. Set by the init method.

Functions

Link copied to clipboard
suspend fun Scene.delay(time: TimeSpan)
Link copied to clipboard
override fun init(injector: Injector)

This method will be called by the SceneContainer that will display this Scene. This will set the injector, views, sceneContainer and resourcesRoot.

Link copied to clipboard
open fun onSizeChanged(size: Size)
Link copied to clipboard
open suspend fun sceneAfterDestroy()

DO NOT BLOCK. Called on the old scene after the transition has been performed, and the old scene is not visible anymore.

Link copied to clipboard
open suspend fun sceneAfterInit()

DO NOT BLOCK. Called after the old scene has been destroyed and the transition has been completed.

Link copied to clipboard
open suspend fun sceneBeforeLeaving()

BLOCK. Called on the old scene after the new scene has been initialized, and before the transition is performed.

Link copied to clipboard
open suspend fun sceneDestroy()

BLOCK. Called on the old scene after the transition has been performed, and the old scene is not visible anymore.

Link copied to clipboard
open suspend fun SContainer.sceneInit()

BLOCK. This is called to setup the scene. Nothing will be shown until this method completes. Here you can read and wait for resources. No need to call super.

Link copied to clipboard
open suspend fun SContainer.sceneMain()

DO NOT BLOCK. This is called as a main method of the scene. This is called after sceneInit. This method doesn't need to complete as long as it suspends. Its underlying job will be automatically closed on the sceneAfterDestroy. No need to call super.