Fix typedefs

This commit is contained in:
2026-06-06 19:06:52 -05:00
parent 9edb2aa0c1
commit 47a6f396fa
5 changed files with 51 additions and 68 deletions
+17 -14
View File
@@ -12,18 +12,14 @@
* @example
* // assets/scenes/game.js
* var scene = {};
* var batch = AssetBatch([{ path: 'tex/bg.png', type: Asset.TYPE_TEXTURE }]);
*
* scene.load = function() { return batch; };
* scene.init = function() { Console.print('scene started'); };
* scene.update = function() { /* per-frame logic *\/ };
* scene.dispose = function() { batch.unlock(); };
* scene.dispose = function() { };
*
* module.exports = scene;
*/
interface SceneObject {
/** Return an AssetBatch to preload before init is called. Optional. */
load?(): AssetBatch | undefined;
/** Called when this scene becomes active. Optional. */
init?(): void;
/** Called every frame while this scene is active. Optional. */
@@ -34,20 +30,27 @@ interface SceneObject {
/** Scene management. */
interface SceneNamespace {
/** `true` while a JS script scene is running. */
readonly active: boolean;
/** The currently active scene object, or `null` if none. */
current: SceneObject | null;
/**
* Loads the JS module at `path`, waits for any `AssetBatch` returned by
* `scene.load()`, then activates the scene (calling `scene.init()`).
* The previous scene's `dispose()` is called just before `init()`.
*
* Returns immediately — the transition is asynchronous.
* Replaces the active scene. Calls `dispose()` on the previous scene (if
* any), then calls `init()` on the new one. Pass `null` to clear.
*
* @example
* Scene.set('assets/scenes/game.js');
* const myScene = require('./scenes/game');
* Scene.set(myScene);
*/
set(path: string): void;
set(newScene: SceneObject | null): void;
/** Called each frame by the engine — drives `current.update()`. */
update(): void;
/** Called each frame by the engine for dynamic/physics updates. */
dynamicUpdate(): void;
/** Disposes the current scene and sets `current` to `null`. */
dispose(): void;
}
declare var Scene: SceneNamespace;