Touch event firing in creator 3.8.2 in native

Hello,
I have added below touch events for a node.

this.dialNode.on(Node.EventType.TOUCH_START, this.onTouchStart, this);
this.dialNode.on(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
this.dialNode.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
this.dialNode.on(Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);

In native, when I tap on the node, it is firing touch-move event instead of touch-start. In web its working fine.
Does anyone know what might be the issue here?
Thank you

I test it in 3.8.2, It works nomally.And I never been in this situation before. Can you show me complete script and nodes structure.

Screenshot 2024-04-30 at 10.51.42 AM
this is the node structure and events are added to sprite node

protected onLoad(): void {
        this.dialNode.on(Input.EventType.TOUCH_START, this.onTouchStart, this);
        this.dialNode.on(Input.EventType.TOUCH_MOVE, this.onTouchMove, this);
        this.dialNode.on(Input.EventType.TOUCH_END, this.onTouchEnd, this);
        this.dialNode.on(Input.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
        this.startTime = Date.now() / 1000;
        this.currentTime = Date.now() / 1000;
    }

    onTouchStart(touch: EventTouch) {
        touch.propagationStopped = true;
        this.isBeingRotated = true;

        // notify listener:
        this.startTime = Date.now() / 1000;
        GameManager.getInstance().getGameUIInstance().handleDialRotateBegin(this);
        this.prevLocation = this.dialNode.getComponent(UITransform)
                            .convertToNodeSpaceAR(new Vec3(touch.getUILocation().x, touch.getUILocation().y))
    }
    onTouchMove(touch: EventTouch) {
        touch.propagationStopped = true;

        console.log(`touch move`)
        const center = new Vec3(0, 0); //this.node.position.clone().add(Utils.getCenter(this.node));

        const centerToPrevPos = this.prevLocation.clone().subtract(center);
        const centerToCurrPos = this.dialNode.getComponent(UITransform)
                                .convertToNodeSpaceAR(new Vec3(touch.getUILocation().x, touch.getUILocation().y))
                                .subtract(center);
                            // console.log('curr pos: ', centerToCurrPos)

        // touch.getLocation().subtract(new Vec2(center.x, center.y));
        let deltaAngle = new Vec2(centerToPrevPos.x, centerToPrevPos.y).signAngle(new Vec2(centerToCurrPos.x, centerToCurrPos.y));

        let sign = deltaAngle < 0 ? 1 : -1;

        this.prevLocation = this.dialNode.getComponent(UITransform)
                            .convertToNodeSpaceAR(new Vec3(touch.getUILocation().x, touch.getUILocation().y))
        
    }

It looks vary normal. Could it be a problem of device?

May be because it’s not happening in all devices though. The issue occured in 2 of the 3 devices I checked

Do you have any idea on what might be possible fix?
I was thinking of adding
if((Date.now() / 1000) - this.startTime < 0.2) return; i
n touchmove

1 Like

You mean if you vary quickly click the node,In web it calls touchStart->touchEnd, but in Android, some times it calls touchStart->touchEnd, some times it calls touchStart->touchMove[->touchMove]->touchEnd?

If it is, I think this is because human fingers are easy to produces tiny movements . As far as I know, There is no perfect soluction,It depending on the circumstances. I use
if(e.getDelta().length() < 1) return;

1 Like

Yes, that seems to be the case.

Okay, will try this
Thank you

Yep, check the delta of movement in the TOUCH_MOVE handler, if it moves a little, just ignore it. this situation may happen on some high dpr devices.

1 Like