freeing objects when then leave the screen
This commit is contained in:
parent
c1a1e9aadf
commit
a84ceea08d
4 changed files with 24 additions and 4 deletions
|
@ -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/ressources/sprites/bonus/bone.png" type="Texture" id=2]
|
||||||
[ext_resource path="res://mini-game/scenes/effets/pick_bonus.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://mini-game/scenes/effets/pick_bonus.tscn" type="PackedScene" id=3]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 24.0183, 9.31512 )
|
extents = Vector2( 24.0183, 9.31512 )
|
||||||
|
|
||||||
|
@ -21,4 +18,6 @@ texture = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="pick_bonus"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="pick_bonus"]
|
||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
||||||
[connection signal="body_entered" from="pick_bonus" to="." method="_on_pick_bonus_body_entered"]
|
[connection signal="body_entered" from="pick_bonus" to="." method="_on_pick_bonus_body_entered"]
|
||||||
|
|
|
@ -18,4 +18,6 @@ texture = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="collision_obstacle"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="collision_obstacle"]
|
||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="notifier" type="VisibilityNotifier2D" parent="."]
|
||||||
[connection signal="body_entered" from="collision_obstacle" to="." method="_on_collision_obstacle_body_entered"]
|
[connection signal="body_entered" from="collision_obstacle" to="." method="_on_collision_obstacle_body_entered"]
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
extends "scroll_movement.gd"
|
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):
|
func _physics_process(delta):
|
||||||
move()
|
move()
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,22 @@
|
||||||
extends "scroll_movement.gd"
|
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):
|
func _physics_process(delta):
|
||||||
move()
|
move()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_collision_obstacle_body_entered(body):
|
func _on_collision_obstacle_body_entered(body):
|
||||||
if body.name == "player2" :
|
if body.name == "player2" :
|
||||||
Signals.emit_signal("die")
|
Signals.emit_signal("die")
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue