Skip to content

Animations and timers

Nathan S edited this page Jun 15, 2020 · 2 revisions

borealis uses the same animations engine as RetroArch. This engine allows to asynchronously animate anything using multiple easing functions.

Animations

An animation is composed of:

  • a subject: a float* that is the target of the animation
  • a duration, in milliseconds
  • a target value: the value that the subject will have at the end of the animation
  • an easing function (sine, cubic, linear...)
  • a tag, used to identify the animation later on
  • a callback executed when the animation ends
  • a callback executed every frame while the animation runs
  • an userdata void* pointer, passed back to both callbacks

You can start an animation anytime on any subject. The float will automatically go from its current value to the target value, in the given duration using the given easing function. The value will be incremented (or decremented) every frame until the animation ends, at which point the target value will be forced (to eliminate rounding errors).

The tag allows to stop running animations earlier - that will not trigger the completion callback. You should use that to avoid running animations on a freed subject and to avoid having two animations running on the same subject.

You can create animations using the menu_animation family of functions.

Timers

Timers allow you to run a callback after the given amount of time is elapsed. They work the same way as animations but they only require a callback and a duration. You can abort them using a tag as well.

You can create timers using the menu_timer family of functions.

Clone this wiki locally