Ctrl+K

StdGameContext

Declaration

public class Strawberry.Core.StdGameContext

A standard game context that can be used for games. For special situations like editors or custom game logic, you may need to implement your own game context using the IGameContext interface.

Implements: Strawberry.Core.IGameContext

Constructors

StdGameContext

Initializes a new instance of the StdGameContext class with the specified width and height.

void StdGameContext(int width, int height)

Parameters:

Name Type Description
width System.Int32 The width of the game context.
height System.Int32 The height of the game context.

Properties

Width

Gets the width of the game context.

int Width { get }

Height

Gets the height of the game context.

int Height { get }

Scenes

Gets the collection of scenes managed by this game context.

SceneCollection Scenes { get }

CurrentSceneIndex

Gets or sets the index of the current scene. When set, the current scene is finalized and the new scene is initialized.

int CurrentSceneIndex { get set }

CurrentScene

Gets the current scene being rendered and updated.

Scene CurrentScene { get }

GraphicsContext

Gets the graphics context associated with this game context.

IGraphicsContext GraphicsContext { get }

InputManager

Gets the input manager associated with this game context.

IInputManager InputManager { get }

SoundManager

Gets the sound manager associated with this game context.

ISoundManager SoundManager { get }

Storage

IStorage Storage { get }

Methods

AddScene

Adds a scene to the game context and initializes it.

void AddScene(Scene scene)

Parameters:

Name Type Description
scene Strawberry.Core.Scene The scene to add.

SetScene

Sets the current scene by its name.

void SetScene(string name)

Parameters:

Name Type Description
name System.String The name of the scene to set as current.

SetScene

Sets the current scene by its name.

void SetScene(int index)

Parameters:

Name Type Description
index System.Int32 The index of the scene to set as current.

OnInitialize virtual

Initializes the game context with the provided game launcher.

void OnInitialize(IGameLauncher launcher)

Parameters:

Name Type Description
launcher Strawberry.IGameLauncher The game launcher providing graphics, input, and sound contexts.

OnBeginUpdate virtual

Called at the beginning of the update cycle. Returns true if the update should proceed.

bool OnBeginUpdate()

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

OnUpdate virtual

Called to update the game logic.

void OnUpdate()

OnFixedUpdate virtual

Called to update the game logic at a fixed time step.

void OnFixedUpdate()

OnEndUpdate virtual

Called at the end of the update cycle.

void OnEndUpdate()

OnBeginRender virtual

Called at the beginning of the render cycle. Returns true if rendering should proceed.

bool OnBeginRender()

Returns: True if rendering should proceed, otherwise false.

OnRender virtual

Called to render the game.

void OnRender()

OnEndRender virtual

Called at the end of the render cycle.

void OnEndRender()