LeCodesdocs

Host globals

Globals provided by the host runtime itself (web viewer, iOS, Android, desktop) rather than injected by the SDK. Available in every project, in every engine.

The frame loop

TypeScript
setLoop(fn: (dt: number) => void): number
clearLoop(id: number): void

Fires every rendered frame. dt is seconds since the previous frame (~0.016 at 60 fps) — for frame-independent motion, scale by it: position += speed * dt.

TypeScript
const id = setLoop(dt => {
  if (Input.key('ArrowRight')) player.x += 120 * dt
})
Note

a loop keeps running until cleared. Anything started in a screen's onOpen must be stopped in its onClose, or it leaks across navigation.

Timers

TypeScript
setTimeout(fn, ms?): number
setInterval(fn, ms?): number
clearTimeout(id): void
clearInterval(id): void

Same semantics as the web, milliseconds. (Contrast: setLoop's dt is seconds.)

Console

TypeScript
console.log(...data) / console.warn(...) / console.info(...) / console.error(...)

The only console methods that exist — no console.table, console.time, etc.

asset() — project resources

TypeScript
asset(path: string): string      // compile-time macro — path must be a string LITERAL

Rewritten by the bundler into the resource import for that file; the returned string is the bundled asset URL. Equivalent to importing the file:

TypeScript
import hero from './hero.png'            // same thing
const tex = await Texture2D.load(asset('./hero.png'))
Note

because it's a macro, asset(someVariable) is a build error. Remote https://… URLs don't need it — pass them as plain strings.

Angle constants

TypeScript
DEG2RAD   // π / 180 — substituted at compile time
RAD2DEG   // 180 / π

Use them at the radians↔degrees boundary (see conventions).

Style<T> (editor-only type)

TypeScript
const preset: Style<UIButton> = { bgColor: '#333', borderRadius: 12 }

Resolves to the partial style object el.style(...) accepts — for typing reusable style presets. A pure type: no runtime existence.