1.0.8 • Published 7 months ago

@pixelation/scene v1.0.8

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

@pixelation/scene

Scene management for the Pixelation Engine.

Installation

npm install @pixelation/scene

Usage

import * as engine from "@pixelation/engine";

// To start using this package, import it into your code.
import * as scene from "@pixelation/scene";

const red = engine.colors.fromHex("#ff0000");
const blue = engine.colors.fromHex("#0000ff");

// Scenes must implement the Pixelation Engine Lifecycle Component interface.
const a: engine.lifecycle.Component = {
    render: (surface) => {
        surface.fillRect(0, 0, surface.width, surface.height, red);
    },
};

const b: engine.lifecycle.Component = {
    render: (surface) => {
        surface.fillRect(0, 0, surface.width, surface.height, blue);
    },
};

// Create a scene switcher with a default scene set.
const switcher = new scene.Switcher(a);

// Update the switcher.
switcher.update(surface, inputs, audio, dt, t);

// Render the current scene.
switcher.render(surface, inputs, dt, t, fps);

// Switch to a different scene.
switcher.switch(
    // The scene to switch to.
    b,
    // The duration of the switch animation.
    2_000
);
1.0.8

7 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago