Switching scenes

My animation has a main scene with 3 buttons linked to different scenes. Each of those 3 scenes has an intro animation. When I click a button from within said scenes, I want to rewind the animation before switching to the clicked scene.

https://dsc.cloud/40757e/3-Phasen-v2.zip

In the attached file, click the first button, wait for the animation to finish. When clicking the second button or third, I would rather not switch instantly, but either play in rewind or to the end and switch after this.

Tried with JS, but have some problems with element property (it's not the clicked element but the complete scene element). And chaining mouse clicks seems to be instant, not one after the other.

Almost like this one, but this is either more complex than I understand or it works differently Animation between timelines - #2 by ktewes

The example that you are citing is timeline-based. You are working with scenes, which requires a slightly different approach: Upon click, the addressed scene is stored in the variable 'sceneToGo', and the current timeline runs backwards. In the first frame of this timeline, a JavaScript is called that checks whether the playback direction is backwards (only then will the scene change be executed).

3-Phasen-v2_kt.hype.zip (435.7 KB)

5 Likes

Kalle, thanks!

It worked fine at first. But now after I have made all buttons clickable, scenes don't switch. I checked all actions and JS, but I don't see where the error is.
Would you be so kind and have another look at my new file?

https://dsc.cloud/40757e/3-Phasen-v2.zip

Hi again! A few issues...

  • You don't need the part of the animation that is crossed out in the screenshot. So, the part where you play the animation in reverse. That's already done by the 'setSceneToGo' script:

hypeDocument.continueTimelineNamed('Main Timeline', hypeDocument.kDirectionReverse, false);

  • In your start scene, you forgot the commands for Button 2 and 3.

  • In Phase 2 scene, you're calling the wrong script in the first frame ('setSceneToGo()' instead of 'switchScene()')

  • You forgot to call the setSceneToGo script on some buttons, or you gave an incorrect instruction (continueTimeline...).

image

Hope, this helps. Best wishes, Kalle

3-Phasen-v2 2_kt.hype.zip (506.3 KB)

3 Likes

OMG … I feel like I had double and triple checked everything. :see_no_evil: Hate when this happens :face_with_raised_eyebrow:
The other maybe were not configured properly because it wasn't working before.

I kept the “outro” animation because I perhaps want to use a different (quicker) animation at the end. While it is convenient to just roll back the animation, sometimes I think it is better to switch faster to the next section.

Many thanks again! :+1:

1 Like