How does Love handle box2d?
Posted: Sun Aug 26, 2012 2:28 pm
Please correct me if I'm wrong about anything here. I'm new to Love! From what I understand, the underlying physics engine is Box2d, which uses an x, y location coordinate in the center of the object. Does Love provide any automatic translation of coordinates when drawing its own objects (like images)? For example, if I have an image that is a circle, I obviously want to draw it in the same location as the physics body. Since the image is drawn from the top left, do I need to adjust for that like so:
or can I do this:
Thanks in advance!
Code: Select all
love.graphics.draw(self.image, self.body:getX() - self.image:getWidth() / 2, self.body:getY() - self.image.getHeight() / 2)
Code: Select all
love.graphics.draw(self.image, self.body:getX(), self.body:getY())