britzl / monarch

Monarch is a Defold screen manager with transition support and a straight forward API
MIT License
163 stars 23 forks source link

Reset timestamp after popup transition is done #84

Closed MinchukSergei closed 2 years ago

MinchukSergei commented 2 years ago

There are no possibility to set timestamp to 0 using monarch because it resets it each time.

1) Popup transition is started 2) Timestamp almost instantly reset to 1 3) Game continued 4) Popup transition is done

In that case game run 0.5 - 1 sec (depending on popup back transition duration) and I don't know how to avoid this.

britzl commented 2 years ago

Thank you for the report. Could you please describe the scenario in more detail?

MinchukSergei commented 2 years ago

@britzl, Hi.

Yes, both are monarch screen. Let me describe in details:

A - this is the simple screen B - is popup

Set in A "timestep below popup" to 0 to make it paused when B is opened.

  1. A - is opened and we are playing the game
  2. B - starts opening. Monarch immediately set timestep to 0 - It's OK
  3. B - animation show in is playing (e.g. 1 sec) - It's OK
  4. B - is opened, show animation is finished - It's OK
  5. We are closing B
  6. B - starts playing the hiding animation (e.g. 1 sec)
  7. Monarch immediately set timestep to 1 (we are not able to avoid this immediate logic) - It's NOT OK
  8. A - is unpaused but B is not completely finished its hiding animation. - It's NOT OK
  9. B - finished animation

So, game is unpaused 1 second earlier than we expect (or maybe only me :) )

I found the workaround:

  1. We are closing B
  2. We create timer.delay(0, true, msg.post(set_time_stemp 0) - to extend the pause duration
  3. When B hide animation is finished we msg.post(set_time_stemp 1) - to unpause the A
britzl commented 2 years ago

Thank you. That clarifies the issue. It seems to me that I should change the logic in Monarch to reset the timestep after the animation has finished.

MinchukSergei commented 2 years ago

Yes, I think it's more natural and intuitive/correct. Thank you!