Skip to main content

IScene

Abstract scene interface for scene lifecycle.

PixelTypePixel type for rendering (e.g., Pixel4, uint8_t) Both enjin1 and enjin2 can implement this interface for compile-time polymorphism. Provides standard scene lifecycle methods (onCreate, onUpdate, onRender, etc.).


Namespace: enjin2

Header: include/enjin2/abstract/iscene.hpp

Public Methods

virtual ~IScene()=default

Virtual destructor for proper cleanup through base pointer.


void onCreate()=0

Called when scene is created.

Called once when the scene is first created. Override to set up initial objects and state.


void onActivate()=0

Called when scene becomes active.

Called when the scene becomes the active scene. Use this to resume animations, start background processes, etc.


void onDeactivate()=0

Called when scene becomes inactive.

Called when the scene is no longer active. Use this to pause animations, stop background processes, etc.


void onDestroy()=0

Called when scene is destroyed.

Use this to clean up scene-specific resources.


void onUpdate(uint16_t deltaTime)=0

Called every frame during update.

deltaTimeTime since last frame in milliseconds Use this for scene-specific update logic that should happen before object updates.


void onRender(ICanvas< PixelType > &canvas)=0

Called during rendering.

canvasTarget canvas for rendering Use this for scene-specific rendering like backgrounds or UI overlays.


uint32_t getId() const =0 const

Get scene ID.

Scene identifier


bool isActive() const =0 const

Check if scene is active.

True if scene is active


bool isInitialized() const =0 const

Check if scene is initialized.

True if scene is initialized