cocos_center_in_parent
Center UI elements in Cocos Creator by attaching Widget components with horizontal and vertical alignment flags to position nodes relative to parent containers.
Instructions
Attach cc.Widget with centering flags on either/both axes.
horizontal=False centers only vertically, and vice versa.
Returns the Widget component id.
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>"
},
"name": "cocos_center_in_parent"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scene_path | Yes | ||
| node_id | Yes | ||
| horizontal | No | ||
| vertical | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |