the only thing i can add to Qcode's reply is that if you want to draw the image over a physics body, you will want to give it the angle of the body as well. so that if you have a box bouncing around, or a ball rolling, the image will match the exact position and angle of the body.
For example you could set up your body as follows: (note: the below code is for love 7.2. To get it to work for 8.0 you may need to change it slightly)
Code: Select all
box = {}
box.body = love.physics.newBody(your_world,400, 300, 0, 0) --this is the physics body
box.shape = love.physics.newRectangleShape(box.body, 0, 0, 50, 50, 0) --the shape is for handling collisions
box.shape:setData(your_data)
box.body:setMassFromShapes()
box.image = love.graphics.newImage("box.png")
I think to get this to work for 8.0 you would have to do something like:
Code: Select all
box = {}
box.body = love.physics.newBody(your_world,400, 300, "dynamic") --this is the physics body
box.shape = love.physics.newRectangleShape(0, 0, 50, 50, 0) --the shape is for handling collisions
box.fixture = love.physics.newFixture( box.body, box.shape)
box.shape:setData(your_data)
box.body:setMassFromShapes()
box.image = love.graphics.newImage("box.png")
i haven't used 8.0 yet, so if that's wrong hopefully someone can correct it.
then in your draw function do:
Code: Select all
local b = box --faster
love.graphics.draw(b.image, b.body:getX(), b.body:getY(), b.body:getAngle(), 1, 1, b.image:getWidth()/2, b.image:getHeight()/2)
good luck!