Ctrl+K

IGameContext

Declaration

public interface Strawberry.Core.IGameContext

Represents the context of a game, providing access to essential components and lifecycle methods for initialization, updating, and rendering. You should implement this interface in your game and launch it using Game class's Run method.

Properties

Width abstract

Gets the width of the game context.

int Width { get }

Height abstract

Gets the height of the game context.

int Height { get }

GraphicsContext abstract

Gets the graphics context used for rendering.

IGraphicsContext GraphicsContext { get }

InputManager abstract

Gets the input manager for handling user input.

IInputManager InputManager { get }

SoundManager abstract

Gets the sound manager for handling audio playback.

ISoundManager SoundManager { get }

Assets abstract

Gets the asset manager of this game context. Used as a Global Asset Manager.

AssetManager Assets { get }

Methods

OnInitialize abstract

Called during the initialization phase of the game.

void OnInitialize(IGameLauncher launcher)

Parameters:

Name Type Description
launcher Strawberry.IGameLauncher The game launcher used to initialize the game.

OnBeginUpdate abstract

Called at the beginning of the update phase.

bool OnBeginUpdate()

Returns: True if the update phase should proceed; otherwise, false.

OnUpdate abstract

Called during the update phase to update game logic.

void OnUpdate()

OnFixedUpdate abstract

Called during the fixed update phase for physics or time-sensitive updates.

void OnFixedUpdate()

OnEndUpdate abstract

Called at the end of the update phase.

void OnEndUpdate()

OnBeginRender abstract

Called at the beginning of the render phase.

bool OnBeginRender()

Returns: True if the render phase should proceed; otherwise, false.

OnRender abstract

Called during the render phase to draw the game.

void OnRender()

OnEndRender abstract

Called at the end of the render phase.

void OnEndRender()

OnResized abstract

Called when the game rendering area (window, surface or canvas) has been resized.

void OnResized(Vector2 size)

Parameters:

Name Type Description
size Strawberry.Math.Vector2 The new size of the rendering area

OnFocusLost abstract

Called when the game has lost the focus (e.g. on windows the game window is minimized).

void OnFocusLost()

OnFocusGained abstract

Called when the game has gained the focus (e.g. on windows the game window focused).

void OnFocusGained()

OnClosing abstract

Called when the game is exiting, just before the application is shutdown.

void OnClosing()

OnGraphicsContextLost abstract

Called when the graphics context is lost (never called on desktop platforms).

void OnGraphicsContextLost()

OnGraphicsContextRestored abstract

Called when the graphics context is restored (never called on desktop platforms). Can be used to restore assets (like textures) on android and web platforms.

void OnGraphicsContextRestored()