Browse Source

Make the new brick breakable

DricomDragon 3 years ago
parent
commit
86255e4781

+ 4 - 0
godot/component/entity/ball/Ball.gd

@@ -47,3 +47,7 @@ func _integrate_forces(state :  Physics2DDirectBodyState):
 func _on_Launcher_interrupt_wave():
 	interrupt_ball()
 
+
+func _on_Ball_body_exited(body: Node):
+	if body.has_method("impact"):
+		body.impact(position)

+ 2 - 0
godot/component/entity/ball/Ball.tscn

@@ -40,6 +40,7 @@ physics_material_override = SubResource( 1 )
 gravity_scale = 0.0
 continuous_cd = 2
 contacts_reported = 2
+contact_monitor = true
 linear_velocity = Vector2( 100, 100 )
 linear_damp = 0.0
 script = ExtResource( 1 )
@@ -56,3 +57,4 @@ lifetime = 0.1
 local_coords = false
 process_material = SubResource( 5 )
 texture = ExtResource( 3 )
+[connection signal="body_exited" from="." to="." method="_on_Ball_body_exited"]

+ 5 - 0
godot/component/entity/brick/Brick.gd

@@ -25,3 +25,8 @@ func damage():
 
 func blow_up():
 	emit_signal("kace_broken")
+	queue_free()
+
+
+func impact(pos: Vector2):
+	damage()