Mob.gd 610 B

12345678910111213141516171819202122
  1. extends RigidBody2D
  2. class_name Mob
  3. var _sprite: AnimatedSprite2D
  4. var _shape: CollisionShape2D
  5. # Called when the node enters the scene tree for the first time.
  6. func _ready() -> void:
  7. _sprite = $Sprite
  8. _shape = $Shape
  9. var mob_types := _sprite.sprite_frames.get_animation_names()
  10. _sprite.play(
  11. mob_types[randi() % mob_types.size()]
  12. )
  13. pass # Replace with function body.
  14. # Called every frame. 'delta' is the elapsed time since the previous frame.
  15. func _process(delta: float) -> void:
  16. pass
  17. func _on_visible_on_screen_enabler_2d_screen_exited() -> void:
  18. queue_free()
  19. pass # Replace with function body.