Skip to content

🛠️ A Plugin for Aseprite exported files.

License

Notifications You must be signed in to change notification settings

theatrejs/plugin-aseprite

Repository files navigation

Copyright License Bundle Size (Gzipped) NPM Version

Aseprite Plugin

🛠️ A Plugin for Aseprite exported files.

Installation

npm install @theatrejs/plugin-aseprite --save

Quick Start

⚠️ This example does not include the preloading of assets.

import {Actor} from '@theatrejs/theatrejs';

import * as PLUGINASEPRITE from '@theatrejs/plugin-aseprite';

import asepriteDataHero from './hero-16x16.json';
import asepriteTextureHero from './hero-16x16.png';

const spritesheetHero = new PLUGINASEPRITE.Aseprite(asepriteTextureHero, asepriteDataHero);

class Hero extends Actor {
    onCreate() {
        this.$timeline = spritesheetHero.createTimeline({$actor: this, $framerate: 8, $loop: true, $tag: 'idle'});
    }
    onTick($timetick) {
        this.$timeline.tick($timetick);
    }
}

With Preloading

import {FACTORIES} from '@theatrejs/theatrejs';

import * as PLUGINASEPRITE from '@theatrejs/plugin-aseprite';

import asepriteDataHero from './hero-16x16.json';
import asepriteTextureHero from './hero-16x16.png';

const spritesheetHero = new PLUGINASEPRITE.Aseprite(asepriteTextureHero, asepriteDataHero);

class Hero extends FACTORIES.ActorWithPreloadables([PLUGINASEPRITE.FACTORIES.PreloadableAseprite(spritesheetHero)]) {
    onCreate() {
        this.$timeline = spritesheetHero.createTimeline({$actor: this, $framerate: 8, $loop: true, $tag: 'idle'});
    }
    onTick($timetick) {
        this.$timeline.tick($timetick);
    }
}