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}.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project_path": "<project_path>"
},
"name": "cocos_scaffold_game_loop"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_path | Yes | ||
| states | No | ||
| rel_path | No | GameLoop.ts |