Animationlib

An animation Library for use with Gideros Studio

View project onGitHub

AnimationLib

An animation Library for use with Gideros Studio

This is helpful for creating and using spritesheets. It can be used with spritesheets that are laid out horizontally.

Frame1 | Frame2 | Frame3 | Frame4 | Frame5 | ...

You can initialise the animation with

local myAnim = animation.new("anim1.png", 6, 4, 1)
where the syntax is animation.new(imageFileName, maxFrames, tickSpeed, scale)
imageFileName is the image that holds all the images horizontally <-- This is important
maxFrames tells the animation the number of frames that the image has.
The dimensions of this image should be FrameWidth x maxFrames
tickSpeed is what determines the speed at which the animation is updated.
While some animations work on time, this one is set up on frames to skip before updating
scale is used if you want to scale your animation to a smaller size (fit retina animation on a normal device)

The other functions available with this library are
animation:setFrame(frameNumber)
the frameNumber is between 1 and maxFrames
animation:play()
starts playing the animation. Generaly automatically started when a new instance is created
animation:pause()
toggles the playing of the animation
animation:stop(atFrame)
stops the animation and sets the frame to the atFrame or the first frame
animation:setPosition(xPos, yPos)
positions the animation sprite to the position xPos, yPos on the screen
animation:setX(xPos)
sets the position of the x co-ordinate of the sprite
animation:setY(yPos)
sets the position of the y co-ordinate of the sprite
animation:setAlpha(theAlpha)
sets the alpha of the sprite
animation:setScale(xScale, yScale)
sets the scale of the sprite, if only one value is passed, it is applied to both x and y
animation:setGroup(theGroup)
This is used to make the sprite part of another sprite object than the stage.

License: If you use this code, you need to attribute it to the Author Jayant C Varma from OZApps (http://www.oz-apps.com) in your credits. If you feel that you would rather pay than to credit, you can make a payment of $25 via PayPal instead.