Is there a way to tell when the map is scrolling?

Started by wizard_wizzle (aka ZeldaHistorian), October 05, 2016, 03:25:21 PM

Previous topic - Next topic
I'd like a script to detect when the map is undergoing a scrolling transition - is that possible? This may be related to Solarus issue #989 (https://github.com/solarus-games/solarus/issues/989), but my screen overlay for map tone scrolls with the map when the hero hits the teletransporter. This is not the desired behavior since all of the lights that I've drawn on the surface move when they should stay stationary. My contingency plan is to disable drawing of those lights at the moment of screen scrolling, but I can't figure out if that's possible.

October 05, 2016, 03:45:43 PM #1 Last Edit: October 05, 2016, 03:50:24 PM by Diarandor
I think it would be nice to have some function to know this from the engine part (you should open a request issue on github). This should be a function of the "camera" entity (or the"game" entity) to get this state. A new event "map:on_opening_transition_started(destination)" could also solve the problem.

At present I think there are very few solutions, and all of them quite dirty. On solution would be to automatically replace teleporters by custom teleporters (which allows fully customization for small details lile this). I can post the last version that I use for custom teleporters if you decide to make this as a workaround (it does work perfectly without issues). (I use custom teleporters to allow jumping over teleporter-stairs without activating the teleportation, like in Link's Awakening.)

EDIT: jumping over a teleporter is allowed for the built-in jump, and that is what the engine does. However I use a custom jump, so I am forced to use custom teleporters to allow jumping over them.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

@wrightmat:
I updated one of the main scripts for custom teleporters (the script is an improved version) that I made some time ago:
http://forum.solarus-games.org/index.php/topic,484.0.html

You can adapt it to define an event "camera:is_scrolling()". But you would need to update the state of that function when the scrolling transition finishes (you can use the event "map:on_opening_transition_finished(destination)" for the map metatable, and use the multi-events script that Christopho made to avoid overriding this function in other scripts).
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

The simple solution is to access the teleporter metatable, and in on_activated, if the transition style is "scroll", simply store a boolean

Yes, MetalZelda's idea is the way to know when a scrolling teletransportation occurs.

I updated the issue, it don't really see how to fix it: https://github.com/solarus-games/solarus/issues/989

Quote from: wrightmat on October 05, 2016, 03:25:21 PM
my screen overlay for map tone scrolls with the map when the hero hits the teletransporter. This is not the desired behavior since all of the lights that I've drawn on the surface move when they should stay stationary.
Actually I am not sure if I understand. Why should the lights stay fixed? Can you explain with screenshots or a video?

October 05, 2016, 06:05:15 PM #6 Last Edit: October 05, 2016, 06:07:20 PM by Diarandor
Yes, you are right. MetalZelda's idea is much better and cleaner for this purpose. The multi-events script may still be necessary, though.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Christopho, I guess I mis-spoke. The lights actually scroll with the map, when they really should stay stationary. Unfortunately my video capture software is acting up at the moment, so I can't get a video.

MetalZelda, that worked perfectly! I used that trick to disable drawing of the lights for about a half second while the map scrolls and it looks pretty good.