I began using LÖVE (and learning lua) yesterday just because.
I'm playing with physics fixing a few shapes to a body, and I can't find a way (variable / function) to get the position of a circle shape since CircleShape:getWorldCenter() was removed on 0.8.0. How am I supposed to get the position of each shape?
I'm now using body:getWorldPoint to convert the points I used to create the shapes, but that position is already somewhere without the need to recalculate it.
Physics: draw all shapes
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Physics: draw all shapes
Yeah, CircleShape is currently missing a function that returns its position. There are plans for 0.8.1 to add CircleShape:getPoint. It's a bit inconvenient, but you have to store the position in a table and fall back to that for now.
The rest of the Shapes has :getPoints() functions that return the positions.
The rest of the Shapes has :getPoints() functions that return the positions.
Shallow indentations.
Re: Physics: draw all shapes
i use a method in my base class to draw the polygons of each body in the world..here's what it looks like
so for each type of shape - polygon or circle, it will draw the shape.
As Boolsheet pointed out, you need to store the circle position/radius in a separate table but it's not a difficult work around
Code: Select all
for _, v in ipairs(self.fixtures) do
local tlx,tly,brx,bry = v:getBoundingBox( )
love.graphics.push()
love.graphics.setColor(0,255,255,50)
love.graphics.rectangle("fill", tlx, tly, brx-tlx, bry-tly)
love.graphics.pop()
local shape = v:getShape()
if shape:getType() == "polygon" then
love.graphics.push()
love.graphics.setColor(self.color)
love.graphics.translate(self.body:getX(), self.body:getY())
love.graphics.rotate(self.body:getAngle())
love.graphics.polygon("fill", shape:getPoints())
love.graphics.pop()
end
if shape:getType() == "circle" then
love.graphics.push()
love.graphics.setColor(self.color)
love.graphics.circle("fill", tlx+((brx-tlx)/2), tly+((bry-tly)/2) ,shape:getRadius(), 20)
love.graphics.pop()
end
massDensityInfo = massDensityInfo.."\nFixture Density: "..v:getDensity()
end
As Boolsheet pointed out, you need to store the circle position/radius in a separate table but it's not a difficult work around
wat ya mean she's in another castle!?
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot], Google [Bot] and 9 guests