Skip to main content
Glama

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 state

State-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

TableJSON Schema
NameRequiredDescriptionDefault
project_pathYes
statesNo
rel_pathNoGameLoop.ts
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it generates code with specific callbacks ('onEnter<PascalCase>' and 'onExit<PascalCase>'), includes runtime API details ('GameLoop.I.current', 'GameLoop.I.go(state)', 'GameLoop.I.reset()'), and describes validation at scaffold time (e.g., 'State-name validation at scaffold time' with rules and error handling via 'ValueError'). It does not mention side effects like file overwriting or permissions, but covers core behavior well.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, starting with the core purpose. Each sentence adds value: explaining states, callbacks, runtime API, validation, and return values. There is no wasted text, and it uses bullet-like formatting for clarity without being verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (generating code with validation and runtime API), no annotations, and no output schema, the description does a good job covering purpose, behavior, parameters, and returns ('Returns {path, rel_path, uuid_standard, uuid_compressed}'). It misses some details like error handling beyond validation or file system impacts, but is largely complete for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning for the 'states' parameter by explaining its purpose ('ordered list, default ["menu", "play", "over"]'), format, and validation rules. It also implies 'project_path' is for file generation and 'rel_path' defaults to 'GameLoop.ts', though not explicitly named. However, it doesn't detail all three parameters fully (e.g., exact usage of 'project_path'), leaving some gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Generate GameLoop.ts — singleton state machine.' It specifies the verb ('Generate'), resource ('GameLoop.ts'), and distinguishes it from sibling tools (e.g., 'cocos_scaffold_audio_controller', 'cocos_scaffold_player_controller') by focusing on a state machine implementation rather than other game components.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context through details like 'singleton state machine' and 'Designers can wire either from the Inspector or from script code,' suggesting it's for game development in Cocos Creator. However, it lacks explicit guidance on when to use this tool versus alternatives (e.g., other scaffolding tools like 'cocos_scaffold_ui_screen'), no prerequisites, and no exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/chenShengBiao/cocos-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server