Scene

represents a collection of entities that draw to a texture

Constructors

this
this()

creates a new scene

Members

Functions

add_manager
T add_manager(T manager)

adds a manager to this scene

begin
void begin()

called internally on scene creation

create_entity
Entity create_entity(string name)

create an entity given a name

create_entity
Entity create_entity(string name, Vector2 pos)

create an entity given a name and a 2d position

create_entity
Entity create_entity(string name, Vector3 pos)

create an entity given a name and a 3d position

end
void end()

called internally on scene destruction

get_entity
Entity get_entity(string name)
Undocumented in source. Be warned that the author may not have intended to support it.
get_manager
Nullable!T get_manager()
Undocumented in source. Be warned that the author may not have intended to support it.
on_start
void on_start()

called at the start of the scene

on_window_resized
void on_window_resized()

window resize event

post_render
void post_render()

run postprocessors

render
void render()

called internally to render ecs

render_hook
void render_hook()

may optionally be used to render global things from a scene

render_scene
void render_scene()
Undocumented in source.
setup
void setup()

setup that hapostprocessorsens after begin, but before the child scene starts

unload
void unload()

called right before cleanup

update
void update()

called internally to update ecs. can be overridden, but super.update() must be called.

update_updatable
void update_updatable(Component component)
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

resolution
Vector2 resolution [@property getter]

gets the render resolution. initialized to Core.default_resolution

resolution
Vector2 resolution [@property setter]

sets the render resolution and updates the render target

Structs

CompositeMode
struct CompositeMode

the mode for compositing a scene onto the display buffer

Variables

clear_color
raylib.Color clear_color;

the cleared background color

composite_mode
CompositeMode composite_mode;

the mode of compositing

ecs
EntityManager ecs;

the entity manager

managers
Manager[] managers;

updatable managers

postprocessors
PostProcessor[] postprocessors;

postprocessors effects

render_target
RenderTarget render_target;

the render target

Examples

create a test game, with a test scene, and update it

import re.util.test : TestGame;

static class TestScene : Scene2D {
    class Plant : Component, Updatable {
        public int height = 0;

        void update() {
            height++;
        }
    }

    override void on_start() {
        // create a basic entity
        auto nt = create_entity("apple");
        // add a basic component
        nt.add_component(new Plant());
    }
}

auto my_scene = new TestScene();

class Game : TestGame {
    override void initialize() {
        load_scenes([my_scene]);
    }
}

auto game = new Game();
game.run();

// make sure scene is accessible
assert(game.primary_scene == my_scene, "primary scene does not match loaded scene");

// make sure components worked
assert(my_scene.get_entity("apple").get_component!(TestScene.Plant)()
        .height > 0, "test Updatable was not updated");

game.destroy(); // clean up

// make sure scene is cleaned up
assert(my_scene.ecs is null, "scene was not cleaned up");

Meta