class Scar::Scene

Overview

A Scene is a container for one independent state of your application, like title screen, in-game, pause menu, ...

A Scene contains Spaces.

Scenes live on an App's scene stack, while only the topmost scene is updated and rendered. This means that you can e. g. push your pause scene onto the stack and pop it off later and your ingame scene will get paused automatically. You could also implement a system that updates and/or renders other scenes, so that your pause scene shows your game in the background.

Example usage:

sc = Scene.new
sc << Space.new("ui", ...)
sc << Space.new("game", ...)
app << sc

Defined in:

scar/scene.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(spaces : Array(Space)) #

[View source]
def self.new #

[View source]
def self.new(*spaces : Space) #

[View source]

Instance Method Detail

def <<(*spaces : Space) #

Adds one or more spaces to the scene and returns self


[View source]
def [](id : String) : Space #

Returns the space with the given id


[View source]
def []?(id : String) : Space | Nil #

Returns the space with the given id or nil when it is not found


[View source]
def reorder_spaces #

Sorts the spaces in the scene by their z value


[View source]
def spaces : Array(Scar::Space) #

[View source]