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 .
tietze111
Prole
Posts: 1 Joined: Mon Jun 18, 2012 5:50 pm
Post
by tietze111 » 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:
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
Thank you in advance,
tietze111
juno
Citizen
Posts: 85 Joined: Thu May 10, 2012 4:32 pm
Location: London
Post
by juno » Mon Jun 18, 2012 7:36 pm
Hey.
There's a couple of small things preventing this from working.
You can create your world like this in 0.8.0..
Code: Select all
world = love.physics.newWorld( 0, 400, true )
When you are creating your body, you need to put the dynamic in " "... ie. pass it as a string
Code: Select all
body = love.physics.newBody( world, 100, 100, "dynamic")
You will also need an update function...
Code: Select all
function love.update(dt)
world:update(dt)
end
That should get you started with making the object and image move
wat ya mean she's in another castle!?
Users browsing this forum: Ahrefs [Bot] , Bing [Bot] and 5 guests