Ball.gd 717 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 destroy() -> void:
  14. queue_free()
  15. func _on_Launcher_interrupt_wave() -> void:
  16. interrupt_ball()
  17. func _on_Ball_body_entered(body: Node) -> void:
  18. if body.has_method("impact"):
  19. body.impact(position)
  20. func _on_Ball_body_exited(body: Node) -> void:
  21. if body.has_method("bounce"):
  22. body.bounce(position)