cocos creator 按钮不规则
时间: 2023-07-29 13:10:20 浏览: 216
cocos creator 不规则形状按钮
5星 · 资源好评率100%
回答: 在Cocos Creator中,要实现按钮的不规则形状,可以利用PolygonCollider组件来实现。首先,需要给按钮节点添加cc.PolygonCollider组件。然后,通过获取cc.PolygonCollider组件,可以使用cc.Intersection.pointInPolygon方法来检测触摸点是否在按钮的不规则形状内。在触摸事件中,需要将触摸点坐标转换为节点坐标系,并确保节点的锚点为(0.5, 0.5),即节点中心为原点。通过这种方式,可以实现按钮的不规则形状。\[3\]
#### 引用[.reference_title]
- *1* *2* [CocosCreator-多边形碰撞组件PolygonColider实现不规则按钮和触摸事件](https://blog.csdn.net/qq_44695727/article/details/123600441)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [cocos creator基础-(七)cc.Button使用、以及不规则按钮区域的实现](https://blog.csdn.net/weixin_30907935/article/details/96622033)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文