Hello everyone. I'm working on an interactive book game and I'm having a couple issues with crossfading from one page to another. For each page, I have a Control node ("Page_000", for example) with a TextureRect for the artwork with Buttons to navigate from page to page. These pages are contained in another Control node ("Pages") that has a script attached to handle the Button signals and perform the transition via a Tween ("Transition Tween"). I have a NinePatchRect ("WindowFrame") overlaying the pages as a or additional controls like a tile bar and progress meters.
The Scene Tree:
The Game Screen:
I've got the crossfading working but I'm having a bit of trouble with getting a couple things: I want to hide the page when it's faded out at the end of the tween, to prevent interaction with it. The WindowFrame's Mouse Filter is working when I change it to STOP, but not changing back to PASS.
I've only been working with GDScript for a couple of weeks so far, so any advice will be most welcome!
Here is the code so far:
extends Control
# Node variables
onready var transition_tween := get_node("../TransitionTween")
onready var window_frame := get_node("../WindowFrame")
# Variable to track the current page
onready var current_page = "Page_000"
func navigate_to(page: String) -> void:
print("Navigate from " + current_page)
# Change the Mouse Filter on the WindowFrame node to prevent clicking buttons during the transition between pages.
window_frame.mouse_filter = Control.MOUSE_FILTER_STOP
# Tween to fade the currently visible page to transparent.
transition_tween.interpolate_property(get_node(current_page), "modulate:a", 1.0, 0.0, 0.5, Tween.TRANS_QUAD, Tween.EASE_OUT)
# Make sure the current_page is hidden
transition_tween.interpolate_callback(get_node(current_page), 0.5, "hide")
# Change the Mouse Filter on the WindowFrame node to allow clicking buttons after the transition between pages.
transition_tween.interpolate_callback(self, 0.5, "enable_buttons")
# Update the current page.
current_page = page
# Make sure the current_page is visible.
get_node(current_page).show()
# Tween to fade the next page from transparent.
transition_tween.interpolate_property(get_node(current_page), "modulate:a", 0.0, 1.0, 0.5, Tween.TRANS_QUAD, Tween.EASE_OUT)
transition_tween.start()
func enable_buttons() ->void:
print(window_frame.mouse_filter)
window_frame.mouse_filter == Control.MOUSE_FILTER_PASS
print(window_frame.mouse_filter)