cocos_make_click_event
Create click event configurations for Cocos Creator buttons to trigger specific script methods when users interact with UI elements.
Instructions
Build a cc.ClickEvent dict for use with cocos_add_button's click_events.
Args: target_node_id: Node that holds the script (array index) component_name: @ccclass name (e.g. 'GameManager') handler: Method name to call (e.g. 'onStartClick')
Returns a dict to pass in click_events list of cocos_add_button.
Example workflow: evt = cocos_make_click_event(scene, gm_node, 'GameManager', 'onStart') cocos_add_button(scene, btn_node, click_events=[evt])
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>",
"target_node_id": "<target_node_id>",
"component_name": "<component_name>",
"handler": "<handler>"
},
"name": "cocos_make_click_event"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scene_path | Yes | ||
| target_node_id | Yes | ||
| component_name | Yes | ||
| handler | Yes | ||
| custom_data | No |