Bind picture to body, apply force to body
Posted: Mon Jun 18, 2012 5:55 pm
Hi,
I wanted to create a body and bind a picture to it. Then I wanted to apply a force to the body (something like gravity) to get the body moving. The picture should move with the body. My attempt for this was:
Thank you in advance,
tietze111
I wanted to create a body and bind a picture to it. Then I wanted to apply a force to the body (something like gravity) to get the body moving. The picture should move with the body. My attempt for this was:
Code: Select all
function love.load()
world = love.physics.newWorld( 0, 0, 1000, 800, xg, yg, sleep )
body = love.physics.newBody( world, 100, 100, dynamic)
background = love.graphics.newImage("background.jpg")
picture = love.graphics.newImage("picture.png")
body:applyForce(0,20)
bxp = 100
byp = 100
end
function love.draw()
bxp = body:getX()
byp = body:getY()
love.graphics.draw(background)
love.graphics.draw(picture, bxp, byp)
end
tietze111