public final class AnimationManager extends Object implements AutoCloseable
IAnimation
objects that are assigned to it.
This class is used by the Map
class. See Map#getAnimationManager
.
Modifier and Type | Class and Description |
---|---|
static class |
AnimationManager.OngoingAnimation
This struct represents an animation that has been
started in AnimationManager and has not been stopped yet. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
finalize() |
AnimationManager.OngoingAnimation |
getCurrentAnimation(String key)
Returns the currently ongoing animation if present or
null if no animation with that key is ongoing. |
void |
startAnimation(String key,
IAnimation animation)
Starts a new animation.
|
void |
stopAnimation(String key)
Stops the animation that was added with the given key, if present.
|
public void close()
close
in interface AutoCloseable
public void startAnimation(@NotNull String key, @NotNull IAnimation animation) throws NullPointerException
Upon starting, the animation manager invokes IAnimation#onStart
on the IAnimation
.
Each animation has a key attached to it. You can stop an animation by invoking AnimationManager#stopAnimation
with this key or you can replace the animation by invoking AnimationManager#startAnimation
with the same key.
key
- The key attached to that animation. If an animation is already playing with that key, the manager stops it before starting the new animation.animation
- The IAnimation
object to be played, cannot be null
.NullPointerException
- when the passed animation is null
.public void stopAnimation(@NotNull String key)
If an animation is currently playing with that key, the manager invokes IAnimation#onStop
on that animation.
key
- The key attached to the animation that should be removed.@Nullable public AnimationManager.OngoingAnimation getCurrentAnimation(@NotNull String key)
null
if no animation with that key is ongoing.key
- The key attached to an animationnull
if no animation with that key is ongoing.