Skip to content

Bug: 04-pinball game runs failed in the real mobile browser #28

@liumu96

Description

@liumu96

When I try to play this pinball game on my iPhone 13, I can't move the flippers. The page doesn't react to the touch action. I debugged the code and found that the problem lies with the touch.identifier.
Initially, the flipper's touchIdentifier was set to -1. I checked if touchIdentifier >= 0 to determine if there was a press action.

this.touchIdentifier = -1;
var pressed = this.touchIdentifier >= 0;
if (flipper.select(touchPos)) {
    flipper.touchIdentifier = touch.identifier;
}       

The problem was the touch.identifier was not always >= 0, for example , it didn't work in iphone 13 (real phone not the web virtual phone.).
So I changed the initial touchIdentifier to null, and determined the press action by checked if touch.identifier was null. The key code is as below:

this.touchIdentifier = null;
var pressed = !!this.touchIdentifier;
if (flipper.select(touchPos)) {
    flipper.touchIdentifier = touch.identifier;
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions