Mob.cs 417 B

1234567891011121314151617
  1. using Godot;
  2. public partial class Mob : RigidBody2D
  3. {
  4. public override void _Ready()
  5. {
  6. var animatedSprite = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
  7. string[] mobTypes = animatedSprite.SpriteFrames.GetAnimationNames();
  8. animatedSprite.Play(mobTypes[GD.Randi() % mobTypes.Length]);
  9. }
  10. public void OnVisibleOnScreenNotifier2DScreenExited()
  11. {
  12. QueueFree();
  13. }
  14. }