- Joined
- Apr 9, 2015
- Messages
- 1,797
- Reaction score
- 863
- First Language
- German
- Primarily Uses
Description
Provides a generic way to animate every float property on every obj
Author
Iavra
Parameters
@param Enable Persistence
@desc If set to true, running animations will be stored in the savefile and continued after loading.
@default false
How to Use
To animate an object a new Tween has to be created and started like this:
var myTween = new IAVRA.ANIMATE.Tween(object, {_x : 100}).duration(50).start();
This will cause the property "_x" of "object" to change from its current value to 100 over the next 50 frames, using linear easing (default).
The IAVRA.ANIMATE.Tween class contains the following functions:
The IAVRA.ANIMATE module contains the following functions:
The second script contains JavaScript implementations of the Robert Penner easing functions, which can be used like this:
new IAVRA.ANIMATE.Tween(object, {...}).easing(IAVRA.EASING.quad.in).start();
Terms of Use
Free to use for both commercial and non-commercial games. Please give credit.
If you use the Easing Library, you must give credit to Robert Penner.
Download
Animate Everything: http://pastebin.com/WqZ1Sfs5
Easing Library: http://pastebin.com/Y6kMyksm
FAQ
Q: Can i rename the script or will it break?
A: You are free to name the files however you want, since i'm using my own method for loading parameters, which doesn't use the filename.
Provides a generic way to animate every float property on every obj
Author
Iavra
Parameters
@param Enable Persistence
@desc If set to true, running animations will be stored in the savefile and continued after loading.
@default false
How to Use
To animate an object a new Tween has to be created and started like this:
var myTween = new IAVRA.ANIMATE.Tween(object, {_x : 100}).duration(50).start();
This will cause the property "_x" of "object" to change from its current value to 100 over the next 50 frames, using linear easing (default).
The IAVRA.ANIMATE.Tween class contains the following functions:
All functions return the Tween object itself and can be used for chaining.start()
Starts the animation.
stop()
Stops the animation. It can be restarted, but the current progress isn't saved.
pause()
Pauses the animation. It can be restrated at any time by calling resume().
resume()
Resumes the animation that has previously been pause()-d.
easing(easing)
Specified the easing function to be used by the tween. By default, linear (no) easing is used. An easing function takes a single parameter k, which is defined as t/d, meaning "current animation step" / "total duration" and can range from 0.0 to 1.0. It must return a value of X, which will be used to calculate the current value as: start + (end - start) * X.
duration(duration)
Sets the animation duration. The default value is 1 and causes the animation to complete instantly. Values lower than 1 will throw an error.
delay(delay)
Causes the animation to pause for a given number of steps and can either be used to delay the start of the animation or to pause it during its execution. Values lower than 1 have no effect.
onStart(callback)
Registers a callback, which will be invoked when the animation starts. The callback receives the animated object as a parameter.
onUpdate(callback)
Registers a callback, which will be invoked when the animation proceeds by one step. The callback receives the animated object as a parameter.
onComplete(callback)
Registers a callback, which will be invoked when the animation completes. The callback receives the animated object as a parameter.
onStop(callback)
Registers a callback, which will be invoked when the tween's stop() function is called. The callback receives the animated object as a parameter.
chain(...)
Takes any number of IAVRA.ANIMATE.TWEEN objects, that will be started once this animation completes. Please ensure not to call start() on the chained objects, as this would cause them to be started twice.
access(get, set)
Takes 2 callback functions, that will be used to read and write properties on the object being animated. The get callback takes 2 parameters, the object and name of the property being read. The set callback takes 3 parameters, the object, the name of the property to write and the value it should be set to.
The IAVRA.ANIMATE module contains the following functions:
By default, animations are saved locally and get lost after saving and loading the game. The parameter "Enable Persistence" changes this and stores all animations in the savefile. Note that JSON.stringify() (which MV uses as its save mechanism) discards functions, which means that registered callbacks are lost after loading a game.clear()
Forcefully stops all currently running animations without triggering callbacks or starting chained tweens.
The second script contains JavaScript implementations of the Robert Penner easing functions, which can be used like this:
new IAVRA.ANIMATE.Tween(object, {...}).easing(IAVRA.EASING.quad.in).start();
Terms of Use
Free to use for both commercial and non-commercial games. Please give credit.
If you use the Easing Library, you must give credit to Robert Penner.
Download
Animate Everything: http://pastebin.com/WqZ1Sfs5
Easing Library: http://pastebin.com/Y6kMyksm
FAQ
Q: Can i rename the script or will it break?
A: You are free to name the files however you want, since i'm using my own method for loading parameters, which doesn't use the filename.
Last edited by a moderator:

