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.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scene_path | Yes | ||
| node_id | Yes | ||
| horizontal | No | ||
| vertical | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |