1.15.0 • Published 2 months ago
@theatrejs/theatrejs v1.15.0
Theatre.js
🎮 A JavaScript 2D Game Engine focused on creating pixel art games.
Installation
npm install @theatrejs/theatrejs --save
Quick Start
⚠️ This example does not include the preloading of assets.
import {Actor, Engine, Sprite, Stage, Vector2} from '@theatrejs/theatrejs';
import textureHero from './hero-16x16.png';
class Hero extends Actor {
onCreate() {
this.setSprite(new Sprite({
$sizeTarget: new Vector2(16, 16),
$texture: textureHero
}));
}
}
class Level1 extends Stage {
onCreate() {
this.createActor(Hero);
}
}
const engine = new Engine();
engine.initiate();
engine.createStage(Level1);
With Preloading
⚠️ Assets are preloaded asynchronously.
asynchronous module
import {Engine, FACTORIES, Sprite, Vector2} from '@theatrejs/theatrejs';
import textureHero from './hero-16x16.png';
class Hero extends FACTORIES.ActorWithPreloadables([FACTORIES.PreloadableTexture(textureHero)]) {
onCreate() {
this.setSprite(new Sprite({
$sizeTarget: new Vector2(16, 16),
$texture: textureHero
}));
}
}
class Level1 extends FACTORIES.StageWithPreloadables([Hero]) {
onCreate() {
this.createActor(Hero);
}
}
const engine = new Engine();
engine.initiate();
await engine.preloadStage(Level1);
engine.createStage(Level1);
synchronous module
...
const engine = new Engine();
engine.initiate();
engine.preloadStage(Level1).then(() => {
engine.createStage(Level1);
});
API
1.15.0
2 months ago
1.14.0
3 months ago
1.13.0
3 months ago
1.12.0
3 months ago
1.11.0
4 months ago
1.2.0
7 months ago
1.1.0
8 months ago
1.0.0
8 months ago
1.9.0
6 months ago
1.8.0
6 months ago
1.7.0
7 months ago
1.6.0
7 months ago
1.3.3
7 months ago
1.5.0
7 months ago
1.3.2
7 months ago
1.4.0
7 months ago
1.3.1
7 months ago
1.3.0
7 months ago
1.2.1
7 months ago
1.10.0
4 months ago
0.1.0
8 months ago