Files
cocos4/cocos/physics-2d/framework/components/joints
James Chen 48308cdbef Fix touch listeners are not unsubscribed in MouseJoint. (#18438)
* MouseJoint Touch Issue

This code ensures that all touch event listeners (TOUCH_START, TOUCH_MOVE, TOUCH_END, and TOUCH_CANCEL) attached to the Canvas node are properly removed when the MouseJoint component is destroyed.

Purpose:
Prevents touch event listeners from remaining in memory after the MouseJoint is destroyed.
Avoids unexpected behavior caused by lingering event handlers that could still trigger interactions.
Improves memory management and performance by ensuring proper cleanup of event listeners.

* Override destroy an remove touch listner from joint

* Fix touch listeners are not unsubscribed in MouseJoint.

* Unsubscribe touch listeners in onDestroy

* Subscribe touch listeners in onEnable/onDisable.

* Optimize code size.

* Remove empty onDestroy.

* Should empty implement MouseJoint.

---------

Co-authored-by: gt3mb <68908903+gt3mb@users.noreply.github.com>
2025-03-11 18:44:36 +08:00
..