Skip to content

fix setPollAlways() hit-testing inactive pointers#7320

Draft
Antriel wants to merge 1 commit into
phaserjs:masterfrom
Antriel:master
Draft

fix setPollAlways() hit-testing inactive pointers#7320
Antriel wants to merge 1 commit into
phaserjs:masterfrom
Antriel:master

Conversation

@Antriel

@Antriel Antriel commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

When scene.input.setPollAlways() is enabled, InputPlugin.updatePoll would hit-tests every pointer in input.manager.pointers on every frame, including the spare touch pointer (id === 1) that Phaser allocates but keeps parked at world (0,0) with active === false until the first real touch.

As a result, an interactive Game Object whose hit area covers world (0,0) receives pointerover / pointerout events from that idle phantom pointer with no user input at all (the mouse is never moved, the screen is never touched).

Modified Phaser example that reproduces this:

class Example extends Phaser.Scene {
    preload() {
        this.load.image('eye', 'assets/pics/lance-overdose-loader-eye.png');
    }

    create() {
        this.input.setPollAlways();

        const sprite = this.add.sprite(0, 0, 'eye').setInteractive();
        this.input.on('gameobjectover', (pointer, gameObject) => {
            gameObject.setTint(0xff0000);
        });
        this.input.on('gameobjectout', (pointer, gameObject) => {
            gameObject.clearTint();
        });

        this.tweens.add({
            targets: sprite,
            x: 100,
            yoyo: true,
            repeat: -1,
            duration: 500
        });
    }
}

const config = {
    type: Phaser.WEBGL,
    parent: 'phaser-example',
    scene: Example
};

const game = new Phaser.Game(config);
…pointerover`/`pointerout` from a parked pointer at world (0,0)
@Antriel

Antriel commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

I'm realizing this fix isn't sufficient here yet, as on touch devices the id 0 pointer (a Mouse) is considered always active, causing the same issue. Should it maybe default to not being active until first actual mouse event happens? That would be a bigger change though.

EDIT: Maybe a simpler fix would be just initializing the x/y to something way out of screen.

@Antriel Antriel marked this pull request as draft June 25, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant