Skip to content

Animations

Mighty Pancake edited this page Apr 7, 2020 · 3 revisions

What is a pancake animation?

Pancake animation is a table that contains important data that is needed to animate and object; change its image every x amount of time. Such animation can then be applied to an object.

How to create animation?

You create animation by typing:

pancake.addAnimation(object_name, animation_name, folder, speed)

Where object_name is the name of the object this animation will be able to be applied to animation_name is the name of action this animation represents (for example running, idle etc.), folder is the path where the animation is and speed is the speed of the animation, so how long a frame should last (expressed in milliseconds; the base value being 150).

NOTE:

Adding animation only declares it, you have to use pancake.changeAnimation() to apply it to object

How to use animations?

You apply your wonderful animations by typing:

pancake.changeAniamtion(object, animation_name)

Where object is the object you want the animation to be applied to and animation_name is the name you gave it upon creation.

NOTE:

You can only apply animations to objects with the same name as the object_name parameter was used when creating the animation. For example:

player_object = pancake.addObject({x = 0, y = 0, width = 1, height = 1, name = "NAME"

pancake.addAniamtion("player", "idle", "images/animations) --Note that last parameter is empty, so it’s set to 150

pancake.changeAnimation(player_object, "idle)

won’t work because `player_object’s name attribute is set to "NAME", instead of "player" and the animation won’t load, because it was designed to be played only for objects with name equal to "player"!

Clone this wiki locally