diff --git a/mini-game/scenes/bonuses/bonus1.tscn b/mini-game/scenes/bonuses/bonus1.tscn index c989bff..00ab209 100644 --- a/mini-game/scenes/bonuses/bonus1.tscn +++ b/mini-game/scenes/bonuses/bonus1.tscn @@ -4,9 +4,6 @@ [ext_resource path="res://mini-game/ressources/sprites/bonus/bone.png" type="Texture" id=2] [ext_resource path="res://mini-game/scenes/effets/pick_bonus.tscn" type="PackedScene" id=3] - - - [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 24.0183, 9.31512 ) @@ -21,4 +18,6 @@ texture = ExtResource( 2 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="pick_bonus"] shape = SubResource( 1 ) + +[node name="notifier" type="VisibilityNotifier2D" parent="."] [connection signal="body_entered" from="pick_bonus" to="." method="_on_pick_bonus_body_entered"] diff --git a/mini-game/scenes/obstacles/obstacle1.tscn b/mini-game/scenes/obstacles/obstacle1.tscn index 26757b4..35213af 100644 --- a/mini-game/scenes/obstacles/obstacle1.tscn +++ b/mini-game/scenes/obstacles/obstacle1.tscn @@ -18,4 +18,6 @@ texture = ExtResource( 2 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="collision_obstacle"] shape = SubResource( 1 ) + +[node name="notifier" type="VisibilityNotifier2D" parent="."] [connection signal="body_entered" from="collision_obstacle" to="." method="_on_collision_obstacle_body_entered"] diff --git a/mini-game/scripts/bonus1.gd b/mini-game/scripts/bonus1.gd index 9d82c9b..4cf306f 100644 --- a/mini-game/scripts/bonus1.gd +++ b/mini-game/scripts/bonus1.gd @@ -1,6 +1,15 @@ extends "scroll_movement.gd" +onready var notifier = $notifier + +func _ready(): + get_node("notifier").connect("screen_exited", self, "_on_screen_exited") + +func _on_screen_exited(): + print("Bonus exited the screen") + queue_free() + func _physics_process(delta): move() diff --git a/mini-game/scripts/obstacle1.gd b/mini-game/scripts/obstacle1.gd index 70b9e3d..b738ac7 100644 --- a/mini-game/scripts/obstacle1.gd +++ b/mini-game/scripts/obstacle1.gd @@ -1,12 +1,22 @@ extends "scroll_movement.gd" + +onready var notifier = $notifier + +func _ready(): + get_node("notifier").connect("screen_exited", self, "_on_screen_exited") + +func _on_screen_exited(): + print("Obstacle exited the screen") + queue_free() + func _physics_process(delta): move() - func _on_collision_obstacle_body_entered(body): if body.name == "player2" : Signals.emit_signal("die") queue_free() +