Interface IAnimationComponent
An animation container. This gives access to the animation, and allows to start a new animation which will replace the old animation.
Inherited Members
Namespace: AGS.API
Assembly: AGS.API.dll
Syntax
public interface IAnimationComponent : IComponent, IDisposable, INotifyPropertyChanged
Properties
| Improve this Doc View SourceAnimation
The currently associated animation.
Declaration
IAnimation Animation { get; }
Property Value
Type | Description |
---|---|
IAnimation | The animation. |
OnAnimationStarted
An event when fires whenever an animation is started on this container.
Declaration
IBlockingEvent OnAnimationStarted { get; }
Property Value
Type | Description |
---|---|
IBlockingEvent | The event. |
Methods
| Improve this Doc View SourceAnimate(IAnimation)
Starts a new animation and waits for it to complete. Note: if an animation is an endless loop, this method will never return (unless the animation is stopped manually).
Declaration
AnimationCompletedEventArgs Animate(IAnimation animation)
Parameters
Type | Name | Description |
---|---|---|
IAnimation | animation | Animation. |
Returns
Type | Description |
---|---|
AnimationCompletedEventArgs | A result to indicate if the animation completed successfully or stopped abruptly. |
AnimateAsync(IAnimation)
Starts a new animation and returns a task for allowing asynchronously waiting for the animation to complete. This allows for doing more things in parallel while the animation is playing, while still having the power to wait for the animation when you're done. Note: if an animation is an endless loop, this task will never complete (unless the animation is stopped manually).
Declaration
Task<AnimationCompletedEventArgs> AnimateAsync(IAnimation animation)
Parameters
Type | Name | Description |
---|---|---|
IAnimation | animation | Animation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<AnimationCompletedEventArgs> | A result to indicate if the animation completed successfully or stopped abruptly. |
Examples
Let's animate our 3 musical instruments to play at the same time and wait for the first one to complete.
var trumpetTask = player1.AnimateAsync(trumpetAnimation);
var pianoTask = player2.AnimateAsync(pianoAnimation);
var drumsTask = player3.AnimateAsync(drumAnimation);
//As we didn't await the tasks yet, the trumpet, piano and drums are playing at the same time.
//Now let's see who finishes first:
var firstTaskToComplete = await Task.WhenAny(trumpetTask, pianoTask, drumsTask);
if (firstTaskToComplete == trumpetTask) await player4.SayAsync("Nice job, trumpet dude!");
else if (firstTaskToComplete == pianoTask) await player4.SayAsync("Nice job, piano dude!");
else await player4.SayAsync("Nice job, drums dude!");
//Now let's wait for all animations to complete:
await Task.WhenAll(trumpetTask, pianoTask, drumsTask);
await player4.SayAsync("Nice job, everybody!");
|
Improve this Doc
View Source
StartAnimation(IAnimation)
Starts a new animation (this does not wait for the animation to complete).
Declaration
void StartAnimation(IAnimation animation)
Parameters
Type | Name | Description |
---|---|---|
IAnimation | animation | Animation. |