Code: Select all
h01 = {}
h01.body = love.physics.newBody(runWorld, 350, 100, "dynamic")
h01.shape = love.physics.newRectangleShape(66, 92)
h01.fixture = love.physics.newFixture(h01.body, h01.shape, density)
However, if I want to use metatable, it does not like "self":
Code: Select all
h01 = {}
function h01:Create()
local this =
{
body = love.physics.newBody(runWorld, 350, 100, "dynamic"),
shape = love.physics.newRectangleShape(66, 92),
fixture = love.physics.newFixture(self.body, self.shape, density)
}
setmetatable(this, h01)
return this
end
Code: Select all
bad argument #1 to 'newFixture' (Body expected, got nil)