diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-09-10 18:16:15 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-09-10 18:16:15 +0200 |
commit | 3fdb011ef62249a514a8eba2556cc9f6ea5ea477 (patch) | |
tree | 3273fe2e4736f6843d1a86ae0bcf5901ffbedc86 /Enemies | |
parent | d200edc1a73f4cb8e7595579a8914301b3248299 (diff) |
next commit
Diffstat (limited to 'Enemies')
-rw-r--r-- | Enemies/Enemy.tscn | 2 | ||||
-rw-r--r-- | Enemies/enemy.gd | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/Enemies/Enemy.tscn b/Enemies/Enemy.tscn index ac2cb22..678b33a 100644 --- a/Enemies/Enemy.tscn +++ b/Enemies/Enemy.tscn @@ -34,5 +34,7 @@ texture_filter = 1 sprite_frames = SubResource("SpriteFrames_n2gm8") [node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."] +process_mode = 3 [connection signal="screen_entered" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_entered"] +[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"] diff --git a/Enemies/enemy.gd b/Enemies/enemy.gd index 5818fb4..ab1ceac 100644 --- a/Enemies/enemy.gd +++ b/Enemies/enemy.gd @@ -5,7 +5,7 @@ const SPEED = 30 func _ready() -> void: - set_physics_process(false) + process_mode = PROCESS_MODE_DISABLED func _physics_process(delta: float) -> void: @@ -20,4 +20,8 @@ func _physics_process(delta: float) -> void: func _on_visible_on_screen_notifier_2d_screen_entered() -> void: - set_physics_process(true) + process_mode = PROCESS_MODE_INHERIT + + +func _on_visible_on_screen_notifier_2d_screen_exited() -> void: + process_mode = PROCESS_MODE_DISABLED |