RPG Maker Forums

Description

Allows animation of every numeric attribute on any object.

Videos

I'm currently working on some scripts to use this.

Prerequisites

(optional) "Iavra Weak Reference" (http://forums.rpgmakerweb.com/index.php?/topic/40868-iavra-weak-reference/) - only if Weak References are used.

How to Use

Place this script below every class that you want to support animating.

Call one of the following methods to start an animation:

IAVRA::ANIMATE.start(<object>, <attributes>, <duration>, <easing>, <delay>, <chain>) <callback><object>.iavra_animate_start(<attributes>, <duration>, <easing>, <delay>, <chain>) <callback># Parameters:# <object>: Object to animate# <attributes>: Attributes, as a hash like {<name> => <target value>}# <duration>: Animation duration, in frames. Defaults to 1.# <easing>: Easing function to use. Defaults to :linear.# <delay>: Delay before starting the animation, in frames. Defaults to 0.# <chain>: If true, the animation will be queued and wait for older ones to finished first. Defaults to false.# <callback>: An optional block to be execute, after the animation finished. "self" refers to the object.# ExampleIAVRA::ANIMATE.start(<object>, {:attr => 100}, 120, :linear, 60, true) {p self}The example will wait 60 frames, before animating the attribute :attr of <object> from its current value to 100 over the duration of 120 frames using linear easing.If :attr is already animating, the animation will be queued and wait for older ones to finish, first.

After the animation completes, the supplied block is called and prints the object to the console.

Most parameters have defaults, so you usually won't need to specify everything.

WARNING: Since the animation data is stored inside the object and procs can't be serialized, make sure to only define a callback if the object either isn't included in the savefile or if you are sure, that the game won't be saved while the animation is running.

To interact with animating objects, the following methods can be used:

# Stops the animation for the specified attributes on the target. If no attributes are specified, stops all animations.IAVRA::ANIMATE.stop(<object>, *attrs)<object>.iavra_animate_stop(*attrs)# Skips the current animation for the selected attribute and advances the queue.IAVRA::ANIMATE.skip(<object>, *attrs)<object>.iavra_animate_skip(*attrs)# Returns the frame of the current animation for the selected attribute. Returns nil if the attribute isn't animating and 0 if the animation is delayed.IAVRA::ANIMATE.step(<object>, attr)<object>.iavra_animate_step(attr)# Returns true, if the object has any active, non-delayed animations.IAVRA::ANIMATE.animating?(<object>)<object>.iavra_animate_animating?All easing functions except :linear are contained in their own library script, so they can be swapped out for your own functions. The position of the library doesn't matter.Configuration

To enable animating for a class (and all of its subclasses), you have to register it first, like this:

CLASSES = { Game_Picture => [ lambda {|a| instance_variable_get:)"@#{a}")}, lambda {|a, v| instance_variable_set:)"@#{a}", v)} ]}Make sure to be as specific as possible (for example, registering your own Windows instead of Window_Base), to avoid unintended side effects.You can alter the default values of some parameters like this:

# Default chaining behaviour. If set to true, all animations will be queued unless you define "false" when starting the animation.DEFAULT_CHAINING = false# Default easing function to use, if none is specified when starting the animation.DEFAULT_EASING = :linearYou can decide to use weak references to animated objects instead of referencing them directly. This adds a dependency to "Iavra Weak Reference":
Code:
WEAK_REFERENCES = false
Terms of UseFree to use for both commercial and non-commercial games. Please give credit.

Credits

Iavra

FAQ

None so far

Changelog

(For changes done prior to release, look into the script)

- 1.00: Release version

- 1.01: Added the "step" method, that was previously removed. It returns the current frame of the active animation for an attribute. Returns 0 for delayed animations and nil if the attribute isn't animating.

- 1.02: Moved the update_animation method to occur before the normal update, since the old version sometimes resulted in strange behaviour.

- 1.03: Added dependency to "Iavra Weak Reference". Objects are now updated from outside and don't need their own update method anymore. They still have their own animation data, though, since checking equality with WeakRefs can be a nightmare.

- 1.04: Added a new configuration option to toggle between Weak and Strong references. "Iavra Weak Reference" is only needed if Weak References are used.

Special Thanks

- Robert Penner (http://robertpenner.com/easing/): For creating the easing functions.

- Exhydra: For testing and reporting a lot of early bugs.

Download

Script: http://pastebin.com/1MgCVWPe

Library: http://pastebin.com/vExVACp5

Latest Threads

Latest Posts

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,469
Members
137,821
Latest member
Capterson
Top