britzl / monarch

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

Incorrect behaviour when sliding windows #90

Closed Morgerion closed 1 year ago

Morgerion commented 1 year ago

I want to make sliding windows like they are done in Royal Match, Toon Blast, Squad Alpha and other top-tier projects. I tried this a few years ago on some custom version of the Monarch (2.15.0?), and it worked:

https://user-images.githubusercontent.com/7888071/227774518-b92536f6-aecf-4bbf-a7fd-4e12e96826ba.mp4

... I have now switched that draft project to a fresh version of Monarch (3.7.0). And it's all broken!

https://user-images.githubusercontent.com/7888071/227774599-a86704e3-a1da-4340-a5ca-2690eaf27b60.mp4

Between the two versions of the project only the Monarch's version has changed. Here is an archive of that version of Monarch that works correctly (this is a custom version based on 2.15.0): monarch__.zip Hopefully this will help make "sliding windows support" available in the new Monarch.

britzl commented 1 year ago

It does indeed look a bit strange. I created a sliding window example myself, and the only thing I notice is that there is a bit of a gap between the window that slides out and the one that slides in:

https://user-images.githubusercontent.com/1300688/228258304-9d3fa1a8-202e-48a3-b496-a112364e266c.mov

https://github.com/britzl/monarch/tree/master/example/slidingwindow

Morgerion commented 1 year ago

It's not a gap. If you set a long sliding time for the windows, you can see that the second window does not start sliding until the first window has finished sliding. And we need both windows to start sliding at the same time.

britzl commented 1 year ago

If you set a long sliding time for the windows, you can see that the second window does not start sliding until the first window has finished sliding.

This is actually incorrect. I found that the default transitions positioned the node that was transitioning in on the screen too far out (twice the window width):

https://github.com/britzl/monarch/commit/fe8341263a72309fabbe29d0dab521a0e16c9120

With the correct offset it works a expected:

https://user-images.githubusercontent.com/1300688/228457758-d50163f7-0918-4741-9aa1-461b08818273.mov

Morgerion commented 1 year ago

Thank you, the solution turned out to be completely workable! The issue can be closed.