添加程序化动画

This commit is contained in:
CortexCore
2023-07-05 14:22:03 +08:00
parent 03321346e4
commit 0faf999071
4 changed files with 426 additions and 174 deletions

View File

@@ -0,0 +1,34 @@
using Godot;
using System;
using System.Net.WebSockets;
namespace BITKit;
[Tool]
public partial class ScriptableAnimation : Node
{
[Export(PropertyHint.Range,"0,1")]
public float Value
{
get => _value;
set => SetValue(value);
}
private float _value;
[Export] protected bool autoPlay;
private void SetValue(float newValue)
{
_value =Math.Clamp(newValue,0,1);
OnSetValue(newValue);
}
protected virtual void OnSetValue(float newValue)
{
}
public override void _Process(double delta)
{
if (autoPlay)
{
Value = (Value + (float)delta)%1;
}
}
}