Loop last scene back to start


(Rick) #1

I did use the search function but my ‘fu’ probably left me so I have to ask.

I have one button that tells Hype to move to the next scene.

I have for example 4 scenes. Last scene, scene 4, I like that button to go back to scene one.
I made a timeline for this ‘next scene’ button and when the user arrives at the last scene (scene 4) that button switches to an identical looking button which when clicked loads the first scene then switches back so you get an infinite forward loop.

Works perfectly. :grinning: Except, yesterday peeking through the posts here I ran into the explanation how to use keyboard keys to transition from 1 scene into another. Problem is if I implement that, my 1 button timeline solution stops working if the user tries to use both. Logically, because my timeline gets skipped or starts at the wrong moment.

Still, I want to use both! :grin:

So eh, any other way to have one button go to scene 1, 2, 3 then back to 1?
Some script like, if scene 1,2,3 go next scene, if scene 4 go to scene 1, maybe? I’m really, really bad at javascript so forgive my ignorance. :sweat:


(Mark Hunte) #2

Add this function.

var scenes = hypeDocument.sceneNames() 

 
if (event.keyCode  == 39  || event.which  == 39 ){

 if ( scenes.indexOf(hypeDocument.currentSceneName()) == scenes.length -1 ){


hypeDocument.showSceneNamed(hypeDocument.sceneNames()[0], hypeDocument.kSceneTransitionCrossfade, 1.1)
 
}else {
 
hypeDocument.showNextScene(hypeDocument.kSceneTransitionCrossfade, 1.1)
 }
console.log(scenes.indexOf(hypeDocument.currentSceneName())); 
return;
} 


if (event.type == "mouseup" ) {
if (element.id == "nextButton"){

if ( scenes.indexOf(hypeDocument.currentSceneName()) == scenes.length -1 ){


hypeDocument.showSceneNamed(hypeDocument.sceneNames()[0], hypeDocument.kSceneTransitionCrossfade, 1.1)
 
}else {
 
hypeDocument.showNextScene(hypeDocument.kSceneTransitionCrossfade, 1.1)
 } 
 console.log(scenes.indexOf(hypeDocument.currentSceneName())); 
return;
}



}

Then point all scenes on scene load at it.
Point all scenes keydown at it and a single button that is a persistent symbol across all scenes


(Rick) #3

OMG!:open_mouth:
Thank you, thank you. I wasn’t aware you helped me out as the notification for this ended up in my spam folder which I just saw.

I will try and see if I can implement this with my 2 left hands when it comes to coding.
Thanks again! :grinning:


(Damion Parsons) #4

I have a similar issue without the interactions.

I’ve animated 2 scenes for a banner ad. The output of the banner needs to be a GIF at 5 fps with 3 loops.

I tried @MarkHunte recommendation on looping in another post. However, that only works for a single scene.

I trying to achieve the same result with 2 scenes. Please help.


Set number of loops
#5

@damionp

I’ve answered your request in another post here.