Variable to navigate to scene


(Jose) #1

Hello,

I have a hype document with a menu scene that has some buttons that navigates to different scenes that are submenus. From than submenus you can go to different scene from which you can sweep to move to the next scene as if you were reading a book. On the last scene of the “book” there is a return button to go to the submenu.

As some “books” in different submenus have the same scenes but the return button, is there any way to define a variable in which, depending on the submenu you came from, the behave of the button is different?

Sorry I haven’t explain it clearly.

Thanks in advance.


(Jonathan Deutsch) #2

The answer is yes, but a proper solution is dependent on your current setup. You’re welcome to post a zip of your .hype document for further advise.

Here are building blocks from a general perspective:

  • you will need to use javascript for this
  • you’ll probably want to keep track of the scenes visited via global variables that are set on scene load so you can reference it later
  • The Hype API provides ways to see what scene you’re on via hypeDocument.currentSceneName()
  • The Hype API also provides ways to change scenes programmatically via hypeDocument.showSceneNamed(sceneName, optionalTransition, optionalDuration)

(Jose) #3

Hello, thanks for your answer.

I’ve created a simple hype document to make it easier for me to explain.

As you can see, there is a menu scene with two buttons that goes to two different submenus. Every submenu has two buttons: one of them purple and the other one in different color for every submenu (cyan and green). If I clic on cyan or green button I can go to the target and then go back to the submenu with the button (back to submenu). With purple I can do that duplicating the purple and then changing the button for each one. I this possible without having to duplicate the scenes?

Thanks again.sample.hype.zip (48.2 KB)


(raph) #4

Hi there,

This is how I would do it. I am interested to see if other people have a neater solution!

sample.hype.zip (50.7 KB)


(Jose) #5

Thanks!! That’s what I was looking for.