mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-07 12:35:55 +00:00
Turret animation controller
This commit is contained in:
parent
f751135597
commit
63aeb0a6e9
2 changed files with 117 additions and 0 deletions
|
|
@ -73,6 +73,19 @@ public partial class PlayerAnimationProvider : Node2D
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
public void SweepSprite(float angle, float sweepAngle)
|
||||
{
|
||||
if (_animatedSprite == null) return;
|
||||
|
||||
var frames = _animatedSprite.SpriteFrames.GetFrameCount("default");
|
||||
|
||||
// Map angle (-SweepAngle/2 to +SweepAngle/2) to frame (0 to 5)
|
||||
float normalizedAngle = (angle + (sweepAngle / 2)) / sweepAngle;
|
||||
int frame = Mathf.Clamp((int)(normalizedAngle * frames), 0, frames);
|
||||
|
||||
_animatedSprite.Frame = frame;
|
||||
}
|
||||
|
||||
public void SetAnimation(Vector2 direction)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue