AnimationGroup Class
An AnimationGroup allows to run a group of Animations sequentially or in parallel.
An AnimationGroup consists of an array of Animations that form the AnimationGroup.
A parallel AnimationGroup runs all contained Animations in parallel, starting at the same time.
A sequential AnimationGroup runs all contained Animations sequentially, starting with the first Animation in the array.
The length of the AnimationGroup will be defined as
- the maximum length of the contained Animations in case of a parallel AnimationGroup
- the sum of all lengths of the contained Animations in case of a sequential AnimationGroup
//We want to animate two GeoLocations to move 100 meters up in altitude at the same time // over a period of 10 seconds to simulate an elevator var elevatorAnimation1 = new AR.PropertyAnimation( geoLocation1, //the object geoLocation1 holds the animated property "altitude", //the property altitude will be animated 500, //the start value of the animation is 500 meters 600, //the resulting value of the animation is 600 meters 10000, //the duration of the elevator climb is 10 seconds (10000 miliseconds) {type: AR.CONST.EASING_CURVE_TYPE.EASE_IN_OUT_QUAD}, //easing curve to simulate acceleration and deceleration ); var elevatorAnimation2 = new AR.PropertyAnimation( geoLocation2, //the object geoLocation2 holds the animated property "altitude", //the property altitude will be animated 500, //the start value of the animation is 500 meters 600, //the resulting value of the animation is 600 meters 10000, //the duration of the elevator climb is 10 seconds (10000 miliseconds) {type: AR.CONST.EASING_CURVE_TYPE.EASE_IN_OUT_QUAD}, //easing curve to simulate acceleration and deceleration ); var animationGroup = new AR.AnimationGroup( AR.CONST.ANIMATION_GROUP_TYPE.PARALLEL, // the animations will run in parallel [elevatorAnimation1, elevatorAnimation2], // the animations in the AnimationGroup {onFinish : beepSound.play} //when finished, play a beep sound that elevators have reached their positions ); // now, start the animation group animationGroup.start();
Constructor
AnimationGroup
-
type
-
animations
-
options
Parameters:
-
type
StringThe type of AnimationGroup. Must either be "parallel" or "sequential". Use of the values defined in AR.CONST.ANIMATION_GROUP_TYPE is suggested.
-
animations
Animation[]The array of animations.
-
options
Object optionalSetup-Parameters to customize additional object properties. Accepted options-properties are
Item Index
Properties
Methods
destroy
()
Destroys the object.
isRunning
()
Boolean
Checks if the Animation is currently running.
Returns:
true if the Animation is currently running, false if the Animation is currently not running.
pause
()
Pauses the Animation.
If the PropertyAnimation is currently not running, the call will have no effect.
resume
()
Resumes the Animation.
If the PropertyAnimation is currently running, the call has no effect. Otherwise, it will either be resumed from the position where it was last paused,
or will start from the beginning if it was not paused.
start
-
loopTimes
Immediately starts the Animation.
Parameters:
-
loopTimes
(defaults to1
) Number optionalDefines how often the animation should be played. A negative value indicates an infinite looping. Must be a whole number.
stop
()
Immediately stops the Animation. Allows manual stopping of the Animation before the animation would automatically stop. The onFinish-trigger will not be fired after a manual stopping.
Properties
Events
onFinish
The trigger will fire when the Animation finishes.
The trigger is null by default, and will thus result in no action executed when the trigger fires. A developer can add custom functionality by assigning a custom function to onFinish.
onStart
The trigger will fire right before the Animation starts.
The trigger is null by default, and will thus result in no action executed when the trigger fires. A developer can add custom functionality by assigning a custom function to onStart.