Anima Minimal Version With Example

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
Party member
Posts: 115
Joined: Wed May 15, 2019 7:49 am

Anima Minimal Version With Example

Post by YoungNeer » Fri Aug 02, 2019 8:13 am

In previous post we talked about the recent addition to Anima - about the typing animation feature. But there's much more to Anima than just typing. And this post will not cover all of it - but only the most frequently used functions. Infact now there are two files - Anima_min.lua and Anima.lua the former which is the minimal version and the latter the full version (which includes staging, rolling back animation,etc) which will not be cover in this post.

Anyways let's get started already.

1. Your First Animation:-

Code: Select all

Anima=require 'Anima_min.lua'
--And since we are not using any advanced features (like staging,rollBack,etc) we will use the minimal version

function love.load()

function love.update(dt)

function love.draw()
	--assuming we have an image data file 'img'
The animation is currently very slow so I recommend you add this to love.load function :-

Code: Select all

	--[u]setScaleSpeed[/u] takes two parameters sx and sy which denotes the scaling speed per frame
Assuming you used the same image I used - you should get this output:-


2. Axe Animation:-

From now on I'm only going to show the essential code. For full source you can download the zip file attached.

Code: Select all

	--move 5 pixels up (frame by frame)
	--same as [u]setMoveSpeed[/u] (in this context); takes two parameters x and y which denotes the moving speed per frame
	--When we have to repeat an animation we do this:-
	--Same as [i]setRepeatMove[/i] (in this context); this means don't repeat movement along x but along y
And note that by default repeat means infinite repeat but you can change that. Anyways for now we want infinte repeat. So we only add the above to love.load

And update would be the same as before but rendering method would be a little different - since we are rendering a quad!

Code: Select all

	--here frame is the current frame (this is a non-Anima thing so is not explained in detail)
If you did everything right then you should see an axe moving up and down. You can try changing animaxe:render with to get an idea of what Anima is basically doing. Anyways I've already done that in source and here's how it looks like-


3. Car Animation:-

The car-body will move in the same way as the axe moved- up and down, so we will not worry about that. But what about the wheels- well you can do setRepeatRotation but the problem is that would flip the direction in which it is rotating and we don't want that. So the way will do this is:-

Code: Select all

function love.load()
	--rotate the tire 360 degrees 
function love.update()
	if tireAnim:animationOver() then
And I'm skipping the rendering part (cause it's the same as before) but anyways here's how the source-file from the zip look:-


4. Shaky Animation:-

In this example we will talk about the recent addition to Anima which allows you to repeat animation a number of times (not just infinite). This can be useful for getting a shaky effect!

I won't show the entire code but here's the gist of it:-

Code: Select all

And this is how the source in the zip-file when executed looks like:-

Please note that the typing animations are not discussed here.
You can find them in this link
The full project is at github
Your contribution will be highly appreciated
(885.36 KiB) Downloaded 99 times
My Github- your contribution is highly appreciated

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests