Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
NC22
Prole
Posts: 9
Joined: Sat Jul 16, 2011 12:36 am

I try to make my own physic object with some image, but image dont match with physic model.
size of image 56x56 . here is a code for example

Code: Select all

function love.load()
love.graphics.setLineWidth(2)
world = love.physics.newWorld(-650, -650, 650, 650)
world:setGravity(0, 150)
boximage = love.graphics.newImage("love_cube.png")
boxbody = love.physics.newBody(world, 150, 0, 150 , 45)
boxshape = love.physics.newRectangleShape(boxbody , 150, 0, 56, 56,9)
end
function love.update(dt)
world:update(dt)
end
function love.draw()
love.graphics.polygon("line", v.s:getPoints())
love.graphics.draw(v.i, boxbody :getX(),  boxbody :getY(), boxbody :getAngle(), 1, 1, 28, 28)
end

Thats screenshot shows how look that in game
Attachments
tr.jpg (14.16 KiB) Viewed 1002 times
Last edited by NC22 on Sat Jul 16, 2011 4:42 am, edited 1 time in total.

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Question about physic objects

The shape is offset, so that makes sense. Try replacing the last line in love.load with

Code: Select all

boxshape = love.physics.newRectangleShape(boxbody, 0, 0, 56, 56)

NC22
Prole
Posts: 9
Joined: Sat Jul 16, 2011 12:36 am

### Re: Question about physic objects

Yes. That was a problem. Thanks for help!

Solemnly07
Prole
Posts: 4
Joined: Thu Aug 04, 2011 12:22 pm

### Re: Question about physic objects

Hi, I'm new here and I know forum rules. (No double posting of same topics).
I think it's quite the same topic but, I also need help.

Does your block move or is it static? Because I want to make an object and place an Image on it.
I want to make the object move along with the image, is it possible?
Because I've been trying to make an "Image" become a Physics "object".
Do you get what I mean?

Sorry, I'm still a fresh apple.
"I need not to be Right, I just don't have to be Wrong"

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Question about physic objects

How you do that in LÖVE is you take an image and you take a body, and you draw that image at the location of the body:

Code: Select all

love.graphics.draw(myimage, mybody:getX(), mybody:getY())
There's more to it, but that's the basic thing to know.

Solemnly07
Prole
Posts: 4
Joined: Thu Aug 04, 2011 12:22 pm

### Re: Question about physic objects

Thanks really helped!
"I need not to be Right, I just don't have to be Wrong"

### Who is online

Users browsing this forum: No registered users and 9 guests