TweenPlayer
namespace Griff.Scenes;
public sealed class TweenPlayer : Component, IDrawEffectPlays a little animation of how its entity is drawn, with no code: grown or shrunk (Scale), moved (Move), turned (Rotate) and faded (Fade) at once, eased, as it appears (OnStart), when its Message is sent, or from a script with Play. A card popping into place, a stamp landing on a page, a score jumping as it changes, a coin bobbing. What’s inside the entity moves and fades with it.
Only how it’s drawn changes: its transform, collider and clickable area stay where they are, so it can’t knock anything over or walk off its place. It plays in real time, held while the game is paused unless it’s on an open panel, so a pause menu’s buttons can pop in. It plays on every player’s machine, from what’s sent to it.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”Amount
Section titled “Amount”public float Amount { get; }How far it’s drawn towards the far end now, from 0 (as the entity is) to 1 (as its values say); an overshooting Ease takes it a little past either end.
public float Delay { get; set; }Seconds it waits before it moves, once set off (held at its start meanwhile): cards appearing one after another.
Direction
Section titled “Direction”public TweenDirection Direction { get; set; }From (the default) starts at the far end and settles to how the entity is; To goes from how it is to the far end and stays there once it ends (until it’s played again or stopped).
Duration
Section titled “Duration”public float Duration { get; set; }Seconds it takes from one end to the other.
public Easing Ease { get; set; }The curve it moves along: Out Back overshoots a little and settles, Out Bounce lands like a dropped ball, Linear keeps one speed.
public float Fade { get; set; }How faded it’s drawn at the far end, from 0 (not at all) to 1 (gone): 1 fades it in, or out with To.
IsPlaying
Section titled “IsPlaying”public bool IsPlaying { get; }True while it’s playing (a looping one, until it’s stopped).
public TweenLoop Loop { get; set; }Once, or over and over: Repeat starts again from the start, Ping Pong goes back and forth.
Message
Section titled “Message”public string? Message { get; set; }The message that plays it (from the start), e.g. “Scored”. Empty plays it only on start, or from a script.
public Vector2 Move { get; set; }How far off its place it’s drawn at the far end, in world units: (0, 1) drops in from a unit above.
OnStart
Section titled “OnStart”public bool OnStart { get; set; }Plays it whenever the entity appears: as the scene starts, as it’s spawned, and each time it’s shown again.
Rotate
Section titled “Rotate”public float Rotate { get; set; }How far it’s turned at the far end, in degrees (counterclockwise): 360 spins it once round.
public float Scale { get; set; }How big it’s drawn at the far end of the tween, times its own size: 0 grows out of nothing, 2 lands from twice its size, 1.3 a pop that settles, 1 keeps its size.
Methods
Section titled “Methods”public void Play()Plays it from the start, even if it’s playing now.
public void Stop()Stops it, and it’s drawn as the entity is.