cocos_scaffold_game_loop
Generate a singleton state machine for game flow management in Cocos Creator, creating inspector-visible callbacks for each state transition.
Instructions
Generate GameLoop.ts — singleton state machine.
states: ordered list, default ["menu", "play", "over"].
Each state name generates a pair of inspector-visible callbacks:
onEnter<PascalCase> and onExit<PascalCase> — so "game_over"
becomes onEnterGameOver / onExitGameOver. Designers can wire
either from the Inspector or from script code.
Runtime API::
GameLoop.I.current // current state name
GameLoop.I.go(state) // transition; fires onExit<old> → onEnter<new>
GameLoop.I.reset() // jump to first stateState-name validation at scaffold time:
at least one state
identifier-safe (no spaces, no leading digits)
no duplicates Violations raise ValueError so the broken template never lands.
Returns {path, rel_path, uuid_standard, uuid_compressed}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | Yes | ||
| states | No | ||
| rel_path | No | GameLoop.ts |