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;
}
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.
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: