Storybook: Page content fades in and out - #2647
Conversation
When you flip a page in the Storybook, what's currently on the page will fade out, the page flipping animation will play, and then the new page content will fade in.
|
Play this branch at https://play.threadbare.game/branches/endlessm/storybook-fade/. (This launches the game from the start, not directly at the change(s) in this pull request.) |
manuq
left a comment
There was a problem hiding this comment.
The Storybook is looking good with the fade out / fade in! There is one error to fix.
| @onready var ui_container: Control = %StoryBookContent | ||
|
|
||
|
|
||
| func _fade_out_ui(): |
There was a problem hiding this comment.
There is an error reported on this line. You probably see it as well in the script editor in yellow:
I think you can fix it by:
- Adding "void" as return type, same as in the
_fade_in_ui()function. - Awaiting for the
tween.finishedsignal instead of returning it.
Check Awaiting signals or coroutines:
Using the
awaitkeyword with a signal or a call to a function that is also a coroutine will immediately return the control to the caller. When the signal is emitted (or the called coroutine finishes), it will resume execution from the point on where it stopped.
|
|
||
| if old_index != -1: | ||
| await _fade_out_ui() | ||
| ui_container.visible = false |
There was a problem hiding this comment.
I would make the added functions _fade_out_ui() and _fade_in_ui() more consistent, by moving this immediate ui_container.visible = false to the _fade_out_ui(). Because _fade_in_ui() already does ui_container.visible = true before tweening.
manuq
left a comment
There was a problem hiding this comment.
@alcole2 sorry, have you tested it? Now the fade-in doesn't happen because of (1) the container is set to invisible before the tweening happens, not after. And there is a new error now (2) because there is no await tween.finished at the end of the function.
|
I tested it, I couldn't tell if the fade out was the same or not but assumed it was because it didn't look that different from before. I'll fix it, sorry about that! |
no problem! |
manuq
left a comment
There was a problem hiding this comment.
Excellent! Works nice now and without any errors.
|
Could be that this works only with the a single 2-pages table of contents? If I try the recording.webm@alcole2 can you open a followup task about this? |
When you flip a page in the Storybook, what's currently on the page will fade out, the page flipping animation will play, and then the new page content will fade in.
Resolves #2645