How to load an animation (AnAL) on a body?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
conradoc
Prole
Posts: 1
Joined: Thu Oct 08, 2015 1:34 am

How to load an animation (AnAL) on a body?

Post by conradoc »

Hello guys. It's my first topic. I'm new on Love world and I am getting started on implementing physics.

Before physics, I was making a 2d game using only basic functions. But now, I want to implement jump, gravity...

Without physics, I was using AnAL file to make the character to move. But now, I want to make it jump, so I need to implement physics. How can I draw this animations on a body?


thanks

Apologize for my English. I'm brazillian
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: How to load an animation (AnAL) on a body?

Post by Karai17 »

You want to keep a handle of the physics body in your player table (or wherever) and poll the body's position every frame, then use that position to draw your animation.

Code: Select all

player.body = love.physics.newBody(world, x, y, type)

love.draw()
  local x, y = player.body:getPosition()
  lov.graphics.draw(animation, x, y)
end
I will note here that body:getWorldCenter might be better than body:getPosition, but I don't know. You will have to experiment.

I will also note that anim8 is a much better library than AnAL, you should consider using that instead.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests