Touch end question?

Anybody could explain how to get touch end if the target is different to touch start? How to implement drag and drop?

@pandamicro please help!!!

Try Node.EventType.TOUCH_CANCEL
If touch ends on position other then target, it will trigger Node.EventType.TOUCH_CANCEL with proper world coordinates.

but I need another target

It even sounds strange to me. TOUCH_END, by its nature, cannot be triggered if TOUCH_START did not happen before, in my opinion. If another target is the parent of the first one, you can catch the bubbling event, but it will not depend on coordinates from the other target, and you will still need to check the intersection by coordinates anyway.

Another option I found is to listen for the global TOUCH_END event from the input, and then check if its coordinates is inside your “other” target coordinates.

You need to perform an action when releasing the touch (or mouse) on any UI element.
For example, you move a unit and release it on the trash bin icon, and the unit gets deleted.

    (event: EventTouch) => {
        if (
        ) {
            // your code