![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | amberlimshin |
I have three main nodes. The book cover, the book opened, and a next icon to flip.
When the player clicks on a recipe icon, the book cover overlay pops up.
I want to make it so that when the player clicks on the next icon, the image changes to book opened.
And if the player clicks next again, the overlay disappears and we return to the game.
onready var clicks = 0
func _ready():
$DrDarlinCover.visible = false
$DrDarlinOpened.visible = false
$nextIcon/nextIcon.visible = false
func _on_recipeIcon_gui_input(event):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT and event.is_pressed():
$DrDarlinCover.visible = true
$nextIcon/nextIcon.visible = true
func _on_nextIcon_gui_input(event):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT and event.is_pressed():
if clicks == 0:
$DrDarlinOpened.visible = true
$DrDarlinCover.visible = false
clicks += 1
if clicks == 1:
$DrDarlinOpened.visible = false
With this code, the book opened image never pops up, and we just return back to the game after book cover disappears.
I laboured at this for days, to no avail. Any help is greatly appreciated! Or if there’s any feedback on how to simplify the code as well. Thank you!