New games every week!
What a Bizarre Bug Blog
30th April 2019
v0.945 : Fixed a bug in the touchscreen code.[/highlight]

RSKGames



When I was playing Golf Solitaire in my android chrome browser found an odd issue where the drag and drop card gets placed in the top left of the screen as seen in the attached screenshot.




-=-=-

I grabbed my Android test device, and sure enough, there it was..
For some really obscure reason, any dropped card ends up stuck in the top left corner.
I opened up Firefox, Edge and most notably, Chrome for testing on the PC, but .. Nope.. Worked fine!

Weird..
I then hit F12 in chrome to open the debug/console thing, and was getting no errors..
Then I hit the little "Mobile View" button..



I mean, I really wasn't expecting that to do anything, but .. Worth a try, surely..
All that "Mobile View" does is change the resolution, right?
...
Huh! Look at that!
The bug was suddenly occurring on my desktop, too!

Seems that switching to "Mobile View" changes any Mouse events to act as if they're Touch events, and the bug was in my Touch code.

Letting go of the touchscreen incorrectly tries to set "Mouse X and Y" co-ordinates of the last touch.. But there's no co-ordinates, because there's nothing touching the screen, resulting in the X and Y values being "N/A".

When I then tried to "drop" the card at "Mouse X,Y", it was moving the card to "N/A,N/A", which then broke the maths, because N/A obviously isn't a number. The card gets stuck at "N/A,N/A", which the system then assumes is 0,0 because.. What else could it be? So that's where the card ends up being drawn.


This is a bug that's been in the engine this entire time, and that I hadn't ever noticed because..

...hmmm..

Because that's not what happens on iOS!!

Which begs the question : Why does it not happen on iOS?!
Maybe iOS retains the position of the previous touch?

*shrugs*

But hey, that's one less bug to worry about!
Only another million or so to go

Thanks for the tip, @RSKGames!
Views 84, Upvotes 15  
Shoebox
New games every week!
Site credits : Site built from the ground up, in php, using Programmer's Notepad 2, and a very bored Jayenkai.
(c) Jayenkai 2023 and onwards, RSS feed 4

Blog - What a Bizarre Bug - AGameAWeek