Code:
Code: Select all
local x, y = 20, 20
local w, h = 10, 8
local world = love.physics.newWorld(0, 0, true)
local body = love.physics.newBody(world, x, y, "static")
local shape = love.physics.newRectangleShape(w, h)
-- local shape = love.physics.newPolygonShape(0, 0, w, 0, w, h, 0, h)
-- local shape = love.physics.newEdgeShape(0, 0, w, h)
local fixture = love.physics.newFixture(body, shape)
fixture:setUserData("test")
fixture:setSensor(true)
local x1, y1, x2, y2 = fixture:getBoundingBox()
print("Bounding box:", x1, y1, x2, y2)
print("Width:", x2 - x1, "Height:", y2 - y1)
print("Expected X bounds:", x - w / 2, x + w / 2)
print("Expected Y bounds:", y - h / 2, y + h / 2)
Code: Select all
Bounding box: 14.700000762939 15.700000762939 25.300001144409 24.299999237061
Width: 10.60000038147 Height: 8.5999984741211
Expected X bounds: 15 25
Expected Y bounds: 16 24