Add cycling animation

This commit is contained in:
Mootfrost777 2024-08-20 04:19:02 +03:00
parent 6b55b595c5
commit b14e869e44
3 changed files with 14 additions and 3 deletions

View file

@ -12,7 +12,7 @@ public class AssetManager
public AssetContainer Player = new() public AssetContainer Player = new()
{ {
Animations = [ "player_look_down" ], Animations = [ "player_look_down", "player_run_up"],
IdleAnimation = "player_look_down" IdleAnimation = "player_look_down"
}; };
} }

View file

@ -46,8 +46,8 @@ public class Player : LivingEntity
switch(AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation)) switch(AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation))
{ {
case ScopeState.Top: case ScopeState.Top:
//if ((graphicsComponent as AnimatedGraphicsComponent).CurrentAnimation.TextureName!="player_run_up") if ((graphicsComponent as AnimatedGraphicsComponent).CurrentAnimation.TextureName!="player_run_up")
//(graphicsComponent as AnimatedGraphicsComponent).Star ("player_run_up"); (graphicsComponent as AnimatedGraphicsComponent).StartCyclingAnimation("player_run_up");
break; break;
case ScopeState.Down: case ScopeState.Down:
StartAnimation("player_run_down"); StartAnimation("player_run_down");

View file

@ -138,6 +138,17 @@ namespace ZoFo.GameCore.Graphics
SetInterval(); SetInterval();
} }
public void StartCyclingAnimation(string startedanimationId)
{
currentFrame = 0;
currentAnimation = animations.Find(x => x.Id == startedanimationId);
currentAnimation.IsCycle = true;
buildSourceRectangle();
SetInterval();
}
public void StopAnimation() public void StopAnimation()
{ {