this code crashes my computer.... trying to make a system where it shows and hides a image with a button

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zubayer

the code…
extends Node2D
func _on_door_button_pressed():
while $“door button”.pressed == true:
if $shoping2.show() == true:
$shoping2.hide()
elif $shoping2.show() == false:
$shoping2.show()
if $“door button”.preesed == false:
pass
pass # Replace with function body.

Format code by pasting it, highlighting it and clicking the { } button.

Magso | 2020-04-30 17:08

:bust_in_silhouette: Reply From: Magso

You don’t need the while loop and because there’s no yield or break in the loop it will be endless and won’t allow the next frame to be loaded, that’s why it crashes.

You’re wanting something like this.

func on_door_button_pressed():
    var shoping = $shoping2
    shoping.visible = !shoping.visible

func on_door_button_pressed():
var shoping = $shoping2
shoping.visible = !shoping.visible

Yes, true!

canlı bahis | 2020-04-30 21:29