Created
April 3, 2023 13:37
-
-
Save brettchalupa/2af7ed29ee3d29340860eaa57f9c2c69 to your computer and use it in GitHub Desktop.
Signals in Godot 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Sprite2D | |
var rotating = true | |
signal rotating_toggled(is_rotating:bool) | |
func _ready() -> void: | |
rotating_toggled.emit(rotating) | |
func _process(delta: float) -> void: | |
if rotating: | |
rotate(delta) | |
func _input(event: InputEvent) -> void: | |
if event.is_action_pressed("ui_accept"): | |
rotating = !rotating | |
rotating_toggled.emit(rotating) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node2D | |
func _process(delta: float) -> void: | |
pass | |
func _on_icon_rotating_toggled(is_rotating) -> void: | |
var text = "" | |
if is_rotating: | |
text = "Rotating: active" | |
else: | |
text = "Rotating: paused" | |
$RotatingStatus.text = text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node2D | |
var rotate_icon = true | |
func _process(delta: float) -> void: | |
if rotate_icon: | |
$Icon.rotate(delta) | |
func _on_timer_timeout() -> void: | |
rotate_icon = !rotate_icon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment