A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
import { defineSystem, Query, Mut, GetWorld, Transform } from 'esengine';
import type { TransformData } from 'esengine';
import { LabelOf } from '../components';
// Keeps each floating label a fixed offset above its emitter. Labels are
// separate entities (not children) so they stay upright and unscaled no matter
// what the emitter does.
export const labelSystem = defineSystem(
[Query(Mut(Transform), LabelOf), GetWorld()],
(labels, world) => {
for (const [, transform, label] of labels) {
if (!world.valid(label.target)) continue;
const target = world.get(label.target, Transform) as TransformData;
transform.position.x = target.position.x;
transform.position.y = target.position.y + label.offsetY;
}
},
{ name: 'LabelSystem' },
);