Animationlib

An animation Library for use with Gideros Studio

AnimationLib

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 importantmaxFrames tells the animation the number of frames that the image has.
The dimensions of this image should be FrameWidth x maxFramestickSpeed 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 areanimation:setFrame(frameNumber)
the frameNumber is between 1 and maxFramesanimation:play()
starts playing the animation. Generaly automatically started when a new instance is createdanimation:pause()
toggles the playing of the animationanimation:stop(atFrame)
stops the animation and sets the frame to the atFrame or the first frameanimation:setPosition(xPos, yPos)
positions the animation sprite to the position xPos, yPos on the screenanimation:setX(xPos)
sets the position of the x co-ordinate of the spriteanimation:setY(yPos)
sets the position of the y co-ordinate of the spriteanimation:setAlpha(theAlpha)
sets the alpha of the spriteanimation:setScale(xScale, yScale)
sets the scale of the sprite, if only one value is passed, it is applied to both x and yanimation: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.