/
anna_klio
/
try
Обзор
Документация
Войти
/
anna_klio
/
try
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
MyGame/AnimationCamera.cs
52 строки
2 KB
Анна Клюковка
Animation of Camera added
08 апр 2024, 22:33
08 апр 2024, 22:33
83e68d1
Код
Авторство
О чём код?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Stride.Core.Mathematics; using Stride.Input; using Stride.Engine; using Stride.Animations; namespace MyGame { public class AnimationCamera : SyncScript { public float AnimationSpeed = 1.0f; private AnimationComponent animationComponent; private PlayingAnimation currentAnimation = null; public override void Start() { animationComponent = Entity.Get<AnimationComponent>(); currentAnimation = animationComponent.Play("Walk"); currentAnimation.TimeFactor = AnimationSpeed; } public override void Update() { if (Input.IsMouseButtonPressed(MouseButton.Right)) { if (currentAnimation.Name == "Walk") { currentAnimation = animationComponent.Crossfade("Up", TimeSpan.FromSeconds(0.5f)); currentAnimation.TimeFactor = AnimationSpeed; currentAnimation.RepeatMode = AnimationRepeatMode.PlayOnce; } else if (currentAnimation.Name == "Up") { currentAnimation = animationComponent.Crossfade("Down", TimeSpan.FromSeconds(0.5f)); currentAnimation.TimeFactor = AnimationSpeed; currentAnimation.RepeatMode = AnimationRepeatMode.PlayOnce; } } if (currentAnimation.Name == "Down" && !animationComponent.IsPlaying("Down")) { currentAnimation = animationComponent.Play("Walk"); currentAnimation.TimeFactor = AnimationSpeed; } } } }