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
fix(examples): the torch waits for a cursor before chasing one
esengine358335accfc6
diff --git a/examples/lighting-2d/src/systems/torch.ts b/examples/lighting-2d/src/systems/torch.tsindex 10b224721..79569e7f2 100644--- a/examples/lighting-2d/src/systems/torch.ts+++ b/examples/lighting-2d/src/systems/torch.ts@@ -1,16 +1,23 @@import {- defineSystem, Query, Mut, Res, Transform, UICameraInfo,+ defineSystem, Query, Mut, Res, Transform, UICameraInfo, Input,} from 'esengine';-import type { UICameraData } from 'esengine';+import type { UICameraData, InputState } from 'esengine';import { Torch } from '../components';// Pin the torch entity (a Point light + a small bright marker sprite) to the// world-space mouse position. UICameraInfo already projects the cursor through// the active camera, so no manual screen→world math is needed.+//+// Until the pointer has actually moved, leave the torch where the scene put it.+// A cursor that has never been over the canvas reads as (0, 0) — the top-left+// corner — and following that puts the room's only light off in a corner, so the+// demo opens on a black screen and stays there for anyone who has not yet moved+// the mouse (and for every screenshot taken of it).export const torchSystem = defineSystem(- [Query(Mut(Transform), Torch), Res(UICameraInfo)],- (torches, camera: UICameraData) => {+ [Query(Mut(Transform), Torch), Res(UICameraInfo), Res(Input)],+ (torches, camera: UICameraData, input: InputState) => {if (!camera.valid) return;+ if (input.mouseX === 0 && input.mouseY === 0) return;for (const [, transform] of torches) {transform.position.x = camera.worldMouseX;transform.position.y = camera.worldMouseY;