File builtin/vn/anim.lua

anim.lua Provides the 'built-in' VN animation functions.

Functions

Anim.createFilmstrip (obj, frames) Returns a new Animator that changes an ImageDrawable's texture based on a list of images and durations.
Anim.createTween (obj, property, startval, endval, duration, interpolator) Returns an Animator providing more control than Anim.tweenFromTo.
Anim.createWait (duration) Returns an Animator that does nothing but wait for the specified duration.
Anim.fromFunction (func, duration) Returns an Animator wrapping the given function.
Anim.interpolateValue (a, b, frac) Interpolates between two values a, b based on a weight factor frac.
Anim.par (...) Creates a new Animator that runs all the given Animator arguments in parallel.
Anim.seq (...) Creates a new Animator that runs all the given Animator arguments in sequence.
Anim.tweenFromTo (obj, property, startval, endval, duration, interpolator) Gradually changes the value of property from startval to endval over the course of duration frames.
Anim.tweenTo (obj, property, endval, duration, interpolator) Calls Anim.tweenFromTo using the current value of the property as its startval.
Anim.waitFor (...) Blocks until all Animators passed as arguments are not (or are no longer) running.
Animator:destroy () Immediately kills any background threads, not bothering to cleanly finish the animation.
Animator:finish () Instantly skips to the end of the animation.
Animator:isRunning () Returns true if the animation is currently running.
Animator:onEnd () Called after the animation ends, either by finishing or by being destroyed.
Animator:onLoopEnd () Called when the current time exceeds the duration
Animator:run (...) Calls start, and waits for the background thread to finish.
Animator:start (loops) Starts a background animation thread.
Animator:update () Gets called every frame once started
FilmstripAnimator:preload () Preloads all textures that would be used in the animation.


Functions

Anim.createFilmstrip (obj, frames)
Returns a new Animator that changes an ImageDrawable's texture based on a list of images and durations.

Parameters:

  • obj: The ImageDrawable that the filmstrip animation should change the texture of.
  • frames: A table of tables, each containing a texture and a duration. Example: {{"image1", 30}, {"image2", 10}}
Anim.createTween (obj, property, startval, endval, duration, interpolator)
Returns an Animator providing more control than Anim.tweenFromTo. When started, gradually changes the value of property from startval to endval over the course of duration frames.

Parameters:

  • obj: The object to change the property of
  • property: The property to change
  • startval: The initial value to set the property to
  • endval: The end value for the property
  • duration: The number of frames to take
  • interpolator: An optional Interpolator object, can be used to create an ease-in, ease-out effect.

See also:

Anim.createWait (duration)
Returns an Animator that does nothing but wait for the specified duration.

Parameters:

  • duration: The wait duration in frames
Anim.fromFunction (func, duration)
Returns an Animator wrapping the given function. The Animator (once started) will call the function every frame with one argument: time / duration.

Parameters:

  • func: The function to call every frame
  • duration: The duration of the animation in frames (holding the skip key can cause the animation to advance multiple frames at once).
Anim.interpolateValue (a, b, frac)
Interpolates between two values a, b based on a weight factor frac.

Parameters:

  • a: The first value
  • b: The second value
  • frac: The weight factor between 0.0 and 1.0, where 0.0 returns a and 1.0 returns b.

Return value:

    A value in-between a and b.
Anim.par (...)
Creates a new Animator that runs all the given Animator arguments in parallel.

Parameters:

  • ...:
Anim.seq (...)
Creates a new Animator that runs all the given Animator arguments in sequence.

Parameters:

  • ...:
Anim.tweenFromTo (obj, property, startval, endval, duration, interpolator)
Gradually changes the value of property from startval to endval over the course of duration frames.

Parameters:

  • obj: The object to change the property of
  • property: The property to change
  • startval: The initial value to set the property to
  • endval: The end value for the property
  • duration: The number of frames to take
  • interpolator: An optional Interpolator object, can be used to create an ease-in, ease-out effect.

See also:

Anim.tweenTo (obj, property, endval, duration, interpolator)
Calls Anim.tweenFromTo using the current value of the property as its startval.

Parameters:

  • obj:
  • property:
  • endval:
  • duration:
  • interpolator:

See also:

Anim.waitFor (...)
Blocks until all Animators passed as arguments are not (or are no longer) running.

Parameters:

  • ...:
Animator:destroy ()
Immediately kills any background threads, not bothering to cleanly finish the animation. Use this method if you want to cancel the animation, use finish if you want to end it cleanly by skipping to the end.

See also:

Animator:finish ()
Instantly skips to the end of the animation.
Animator:isRunning ()
Returns true if the animation is currently running.
Animator:onEnd ()
Called after the animation ends, either by finishing or by being destroyed.
Animator:onLoopEnd ()
Called when the current time exceeds the duration
Animator:run (...)
Calls start, and waits for the background thread to finish.

Parameters:

  • ...:

See also:

Animator:start (loops)
Starts a background animation thread.

Parameters:

  • loops:
Animator:update ()
Gets called every frame once started
FilmstripAnimator:preload ()
Preloads all textures that would be used in the animation.

Valid XHTML 1.0!