cocos_add_label
Add text labels to Cocos Creator game scenes with customizable styling, overflow handling, and design token presets for consistent UI theming.
Instructions
Attach cc.Label. overflow: 0=NONE 1=CLAMP 2=SHRINK 3=RESIZE_HEIGHT. cache_mode: 0=NONE 1=BITMAP 2=CHAR. CLAMP truncates, SHRINK auto-shrinks font.
Design-token presets (override the equivalent explicit arg):
color_preset: e.g."text","primary","danger"size_preset:"title"|"heading"|"body"|"caption"outline_color_preset: e.g."bg"for dark outline on light Set the theme once viacocos_set_ui_theme; un-themed projects fall back todark_gamedefaults so presets always resolve.
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": {
"scene_path": "<scene_path>",
"node_id": "<node_id>",
"text": "<text>"
},
"name": "cocos_add_label"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scene_path | Yes | ||
| node_id | Yes | ||
| text | Yes | ||
| font_size | No | ||
| color_r | No | ||
| color_g | No | ||
| color_b | No | ||
| color_a | No | ||
| h_align | No | ||
| v_align | No | ||
| overflow | No | ||
| enable_wrap | No | ||
| line_height | No | ||
| enable_outline | No | ||
| outline_width | No | ||
| cache_mode | No | ||
| color_preset | No | ||
| size_preset | No | ||
| outline_color_preset | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |