Ball.gd 677 B

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