Author Topic: Is there a way to tell when the map is scrolling?  (Read 2489 times)

wizard_wizzle (aka ZeldaHistorian)

  • Sr. Member
  • ****
  • Posts: 263
    • View Profile
Is there a way to tell when the map is scrolling?
« on: October 05, 2016, 03:25:21 pm »
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.

Diarandor

  • Hero Member
  • *****
  • Posts: 1061
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Is there a way to tell when the map is scrolling?
« Reply #1 on: October 05, 2016, 03:45:43 pm »
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.
« Last Edit: October 05, 2016, 03:50:24 pm by Diarandor »
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Diarandor

  • Hero Member
  • *****
  • Posts: 1061
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Is there a way to tell when the map is scrolling?
« Reply #2 on: October 05, 2016, 04:27:16 pm »
@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.”

MetalZelda

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
Re: Is there a way to tell when the map is scrolling?
« Reply #3 on: October 05, 2016, 05:00:33 pm »
The simple solution is to access the teleporter metatable, and in on_activated, if the transition style is "scroll", simply store a boolean

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1185
    • View Profile
Re: Is there a way to tell when the map is scrolling?
« Reply #4 on: October 05, 2016, 05:12:27 pm »
Yes, MetalZelda's idea is the way to know when a scrolling teletransportation occurs.

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1185
    • View Profile
Re: Is there a way to tell when the map is scrolling?
« Reply #5 on: October 05, 2016, 05:26:59 pm »
I updated the issue, it don't really see how to fix it: https://github.com/solarus-games/solarus/issues/989

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?

Diarandor

  • Hero Member
  • *****
  • Posts: 1061
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Is there a way to tell when the map is scrolling?
« Reply #6 on: October 05, 2016, 06:05:15 pm »
Yes, you are right. MetalZelda's idea is much better and cleaner for this purpose. The multi-events script may still be necessary, though.
« Last Edit: October 05, 2016, 06:07:20 pm by Diarandor »
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

wizard_wizzle (aka ZeldaHistorian)

  • Sr. Member
  • ****
  • Posts: 263
    • View Profile
Re: Is there a way to tell when the map is scrolling?
« Reply #7 on: October 07, 2016, 03:52:23 am »
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.