Skip to content

Animation API

Neer edited this page Nov 18, 2019 · 4 revisions

Animation:init()

An internal function to set internal variables for the animation to some default values!

Animation:update(dt)

Updates the animation! You would normally never update an animation manually and leave it all to animX by doing animx.update(dt)!

Animation:render(...)

Renders the Animation based on given parameters. Basically love.draw parameters starting from x!

animation=Animation:addFrame(x,y,w,h,delay)

The addFrame concept was stolen from BartBes' animation library. Anyways what this func does is create a new quad and associate it with the given animation. The frame would be appended to the last of the framelist!

animation=Animation:onAnimOver(fn)

Handler fn called when an entire animation is over

animation=Animation:onCycleOver(fn)

Handler fn called when an animation cycle is over

animation=Animation:onAnimStart(fn)

Handler fn called when an animation is just started

animation=Animation:onAnimRestart(fn)

Handler fn called when an animation is restarted (using Animation:restart()

animation=Animation:onChange(fn)

Handler fn called when an animation proceeds to new frame!

animation=Animation:onUpdate(fn)

Handler fn called at every frame regardless of whether the animation is running or not!

animation=Animation:rewind(times)

Rewind the entire animation any number of times, (nil or negative)=>infinite

animation=Animation:bounce(times)

Bounces the animation each time a cycle is complete! rewind and bounce may look familiar but the way they function are completely different in that rewind does its job when the entire animation is over and not just a cycle (two cycles make up an animation for this context)! Also bounce by default reverses only once while rewind rewinds forever

animation=Animation:loop(times,dir)

Loops the animation in obverse or reverse direction (obverse by default) any number of times or infinitely (if times is nil or negative)

animation=Animation:reverse(times)

Same as loop just direction is always reversed

animation=Animation:once()

Executes an animation once in the obverse direction!

noOfFrames=Animation:getSize()

Gets the total number of frames in animation

times=Animation:getTimes()

Gets the total number of times the animation has been played

curFrame=Animation:getCurrentFrame()

Gets the current Frame of the animation

quad=Animation:getCurrentQuad()

Gets the current quad that's being rendered

isActive=Animation:isActive()

Gets whether or not is the animation active!

width,height=Animation:getDimensions()

Gets the dimensions of the current frame

width=Animation:getWidth()

Gets the width of the current frame

height=Animation:getHeight()

Gets the height of the current frame

animation=Animation:setStyle(style)

Sets the style for the source/atlas of the animation! Basically rough or smooth each making it more or less pixelated!

image=Animation:getAtlas()

Returns the source (image) for the animation

animation=Animation:setAtlas(img)

Sometimes you may want to change the atlas (maybe for something like character clothes) This function changes the texture for the animation

animation=Animation:jumpToFrame(n)

Sets the current frame as n!

animation=Animation:restart()

Restarts the animation from where it was originally!

animation=Animation:stop()

Stops the animation! Use animation.active=false if you don't want to trigger any callback!

delay=Animation:getDelay(frame)

Gets the duration of the given frame or current frame if provided nil

animation=Animation:setDelay(delay)

Sets the delay for all the frames

animation=Animation:setDelay(frame,delay)

Sets the duration of the given frame!

mode=Animation:getMode()

Gets the current animation mode

isMode=Animation:isMode(...)

Check if current mode is equal to one of the given modes

animation=Animation:flip(x,y)

Flips the animation along given axes (boolean values)

animation=Animation:flipX(b)

Flips the animation along x-axis if b is some truthy value.

animation=Animation:flipY(b)

Flips the animation along y-axis if b is some truthy value.

exportSuccessful=Animation:exportToXML(filename)

Exports the animation to XML!

Aliases

Animation.getTexture=Animation.getAtlas
Animation.getImage=Animation.getAtlas
Animation.getSource=Animation.getAtlas
Animation.setTexture=Animation.setAtlas
Animation.setSource=Animation.setAtlas
Animation.setImage=Animation.setAtlas
Animation.getTotalFrames=Animation.getTimes
Animation.draw=Animation.render
Animation.goToFrame=Animation.jumpToFrame
Animation.setFrame=Animation.jumpToFrame
Animation.getActive=Animation.isActive
Animation.onAnimationStart=Animation.onAnimStart
Animation.onAnimationOver=Animation.onAnimOver
Animation.onAnimationRestart=Animation.onAnimRestart
Animation.onFrameChange=Animation.onChange
Animation.onTick=Animation.onUpdate