Browse Source

Color ball when interrupting

DricomDragon 3 years ago
parent
commit
662ef29086
2 changed files with 9 additions and 1 deletions
  1. 1 0
      godot/scenes/Ball.tscn
  2. 8 1
      godot/scripts/Ball.gd

+ 1 - 0
godot/scenes/Ball.tscn

@@ -22,6 +22,7 @@ contacts_reported = 1
 linear_velocity = Vector2( 100, 100 )
 linear_damp = 0.0
 script = ExtResource( 2 )
+interrupt_color = Color( 0.705882, 0.705882, 0.705882, 1 )
 
 [node name="Circle" type="CollisionShape2D" parent="."]
 shape = SubResource( 2 )

+ 8 - 1
godot/scripts/Ball.gd

@@ -1,6 +1,8 @@
 class_name Ball
 extends RigidBody2D
 
+export (Color) var interrupt_color = Color.white
+
 
 signal kace_contact
 
@@ -10,6 +12,11 @@ const interrupt_speed = 700
 const contact_corrector = 3.0
 
 
+func interrupt_ball():
+	modulate = interrupt_color
+	go_down_unstopped()
+
+
 func go_down_unstopped():
 	linear_velocity.y = interrupt_speed
 	linear_velocity = linear_velocity.normalized() * interrupt_speed
@@ -25,5 +32,5 @@ func _integrate_forces(state :  Physics2DDirectBodyState):
 
 
 func _on_Launcher_interrupt_wave():
-	go_down_unstopped()
+	interrupt_ball()