/// <summary>Changes the framerate of this animation.</summary> public void ChangeFrameRate(int newRate) { FrameRate = newRate; // For each actively running animation.. if (FirstInstance != null) { // What's the delay in seconds of a frame? float newDelay = 1f / (float)FrameRate; // For each.. SPAInstance current = FirstInstance; while (current != null) { if (current.Animation == this) { current.FrameDelay = newDelay; } // Hop to the next one: current = current.InstanceAfter; } } }
public override void GoingOffDisplay() { if (Animation != null) { Animation.Stop(); Animation = null; } }
public override void GoingOnDisplay(Css.RenderableData context) { if (Animation == null && SPAFile != null) { Animation = SPAFile.GetInstance(); // Set the event context now: Animation.SetContext(context); } }
/// <summary>Gets how many animations are actively playing.</summary> /// <returns>The number of animations currently playing.</returns> public static int ActiveCount() { int count = 0; SPAInstance current = FirstInstance; while (current != null) { count++; current = current.InstanceAfter; } return(count); }
/// <summary>Advances playback of any running animations and performs some garbage collection. /// Called by <see cref="UI.Update"/>.</summary> public static void Update(float deltaTime) { // Advance any active animations. // These are all animations in our Instance chain. if (FirstInstance != null) { SPAInstance current = FirstInstance; while (current != null) { current.Update(deltaTime); current = current.InstanceAfter; } } }
/// <summary>A shortcut for instancing it.</summary> public Material Start(Shader shader) { if (SPAFile == null) { throw new Exception("Tried to load a broken SPA."); } if (Animation == null) { Animation = SPAFile.GetInstance(); } // Setup using the given shader: Animation.Setup(shader); return(Animation.AnimatedMaterial); }
/// <summary>Creates a playable instance of this animation. /// Instances are required as the same animation could be visible multiple times.</summary> /// <returns>A playable form of this animation.</returns> public SPAInstance GetInstance() { // Create the instance: SPAInstance instance = new SPAInstance(this); // Push the instance to the global animate queue. if (FirstInstance == null) { FirstInstance = LastInstance = instance; } else { instance.InstanceBefore = LastInstance; LastInstance = LastInstance.InstanceAfter = instance; } return(instance); }
/// <summary>Clears all active SPA animations.</summary> public static void Clear() { LastInstance = FirstInstance = null; }