godot-demo-projects/mono/dodge_the_creeps/Mob.cs

18 lines
425 B
C#

using Godot;
public partial class Mob : RigidBody2D
{
public override void _Ready()
{
var animSprite = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
animSprite.Playing = true;
string[] mobTypes = animSprite.Frames.GetAnimationNames();
animSprite.Animation = mobTypes[GD.Randi() % mobTypes.Length];
}
public void OnVisibilityScreenExited()
{
QueueFree();
}
}