Ball.gd 586 B

1234567891011121314151617181920212223242526272829303132
  1. class_name Ball
  2. extends RigidBody2D
  3. export (Color) var interrupt_color = Color.white
  4. const BRICK_LAYER = 2
  5. const INTERRUPT_SPEED = 700
  6. var last_normal:Vector2 = Vector2(0.0, 0.0)
  7. func interrupt_ball():
  8. modulate = interrupt_color
  9. go_down_unstopped()
  10. func go_down_unstopped():
  11. linear_velocity.y = INTERRUPT_SPEED
  12. linear_velocity = linear_velocity.normalized() * INTERRUPT_SPEED
  13. set_collision_mask_bit(BRICK_LAYER, false)
  14. func _on_Launcher_interrupt_wave():
  15. interrupt_ball()
  16. func _on_Ball_body_exited(body: Node):
  17. if body.has_method("impact"):
  18. body.impact(position)