Skip to content

bug: mouse click event has questionable behavior that changes on scene switch #1051

@imaginarny

Description

@imaginarny

Bug Description

Prepare for curse. Order of mouse click events are probably questionable and their behavior changes on scene switch/restart.

Version

master

Playground Link

https://play.kaplayjs.com/?code=eJyllE1P3DAQhu%2F5FYN7caQ0pC1UaBGtWo4UCalHxME4gzfaYEf%2BUItW%2FPeO4yTr3UI5NIdIM34zfub1OBsx9OKJb%2BFeyI2yJuh2Bezd2cnnU5QMnsvzouiNaH8OtvPI2SCCQ1YBO5YWfx2PYT1oxUi4p6OqmYyil1TrznljM%2BGUmLWFk6hJp8Rj3JSXcPEFtgXQI412HuICXIBoW357Rx%2FElZirjb42hHZj0TmevmvxPqi6NyrVg8cogCEqQIqg1v6IlXHTWOQhaOk7o8EbpXq8iX1SmbT3ssvYfksAR1m4SMbwGnWoB%2BNIRL14tLysI25T7ZX4Cg2sYI0dYfBy6uR5gpk6usKn1M8tG6Jl6KQYkN1VOeTcQPJnrD4btIC5vcMsqx2xcfykgrMsJSwKnsUP3W9s58RseRoDoy%2F7Tm74v2miIX8RCS3XxnKWLDpEOjRusSnTWZSef2po9WN8bcGKtgtuBR8amuKdzgTfdzRT1Ob3H98ur8qlkQyUXA7jYO2O8EXebHlMHHC%2FPyWSJku6%2FHa8YvLsaWJ421TSeWH9f8O%2Bxjrf0bdxI8bCm%2B6cMtPljSM9%2Fkx2mfPiDxPqQ7k%3D&version=master

Extra information

I don't know what the truth is anymore or what's the correct way to do something like in the example. But I'm going to describe what user would expect vs what's happening.

Image

By clicking on pause icon, game object gets paused and shouldn't trigger click event anymore (imagine flappy bean jumping on click); But it is triggered right away. And then when you restart scene, behavior switches - it doesn't get triggered on the first click to pause, but on the second click to unpause does.

Then, when the pauseMenu appears, there is a play icon that when you click, it resumes the game. Game event shouldn't be triggered and it isn't; Now, that changes when you click the history icon instead that restarts the scene. Play button will now trigger game click event when clicked to resume.

Now, the initial logic for the pause button will change, if you move the const game.. code with its listener to the bottom. It won't trigger game click event on first click, but will on the second to resume.

It all kinda makes sense, but something is going on as behavior changes. And I'm not sure what the solution should be besides that swithing behavior. Getting to scary stuff similar to event bubbling and propagation?

Sidenote: in the latest alpha26 pauseMenu won't even appear as there was some bug with onClick/mousePress fixed probably. And in the alpha25 pauseMenu buttons are not working. In alpha24, there was no change in behavior when restarting the scene, only initial pause click is also captured by game. Not sure if it gradually lead to this or related.

It was discovered when adding Pausing guide with updating the pause menu example on KAPLAYGROUND along which kind of defies the way it is done or what's possible. Halp.

Summary

  • Fixed in v4000
  • Fixed in v3001

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions