Optionaloptions: TimerPluginOptions<G>const ecs = ECSpresso
.create<Components, Events, Resources>()
.withPlugin(createTimerPlugin())
.build();
// Spawn entity with timer
ecs.spawn({
...createRepeatingTimer(5),
spawner: true,
});
// React to timer completion in a system
ecs.addSystem('spawn-on-timer')
.addQuery('spawners', { with: ['timer', 'spawner'] })
.setProcess((queries, _dt, ecs) => {
for (const { components } of queries.spawners) {
if (components.timer.justFinished) {
ecs.spawn({ enemy: true });
}
}
});
Create a timer plugin for ECSpresso.
This plugin provides:
justFinishedflag pattern for one-frame completion detection