Mob.cs 413 B

123456789101112131415161718
  1. using Godot;
  2. public class Mob : RigidBody2D
  3. {
  4. public override void _Ready()
  5. {
  6. var animSprite = GetNode<AnimatedSprite>("AnimatedSprite");
  7. animSprite.Playing = true;
  8. string[] mobTypes = animSprite.Frames.GetAnimationNames();
  9. animSprite.Animation = mobTypes[GD.Randi() % mobTypes.Length];
  10. }
  11. public void OnVisibilityScreenExited()
  12. {
  13. QueueFree();
  14. }
  15. }