How to prevent scene from restarting when new layout is loaded

(Andrew Silke) #1

I have a layout for vertical phone, and landscape phone… when the user tilts the phone, the whole scene restarts, which is awkward because there is a long animation in the scene, that they then need to rewatch each time, how do i make it NOT restart when a user tilts their phone.


Hi Andrew!

One idea using JavaScript (have not tried it). I do not know of a way strictly using the Hype interface.

In a function e.g. “trackAnimationTime” - going from the horizontal to vertical layout.

"On Layout Unload" handler (“Horizontal” layout)

Get the current time of the animation timeline You are running: “Main Timeline” in this case and using a global variable named currentTimeMain

window.currentTimeMain = hypeDocument.currentTimeInTimelineNamed('Main Timeline');

"On Layout Load" handler (“Vertical” layout):

hypeDocument.goToTimeInTimelineNamed(currentTimeMain, 'Main Timeline');

Note: I’ve shown this going from just one layout to another. You will need to adapt a more robust script so You can swap any needed layouts, such as going back to the horizontal from the vertical, the opposite of what we’ve just done.