Code: Select all
function Block:beginCon(a, b, collision)
if a == self.fixture and b == pong.fixture then
table.remove(ActiveBlocks, instance)
elseif b == self.fixture and a == pong.fixture then
table.remove(ActiveBlocks, instance)
end
end
function Block:beginConAll(a,b, collision)
for i, instance in ipairs(ActiveBlocks) do
instance:beginCon(a, b, collision)
end
end
Code: Select all
function Block:beginCon(a, b, collision)
table.remove(ActiveBlocks, instance)
end
Block is a OOP object, or how you call it, this is how i declared it
Code: Select all
Block = {}
Block.__index = Block
ActiveBlocks = {}
function Block:new(x, y, w, h, r, g, b)
local instance = setmetatable({}, Block)
instance.x = x
instance.y = y
instance.w = w
instance.h = h
instance.r = r
instance.g = g
instance.b = b
instance.body = love.physics.newBody(world, instance.x, instance.y, "static")
instance.shape = love.physics.newRectangleShape(instance.w, instance.h)
instance.fixture = love.physics.newFixture(instance.body, instance.shape)
table.insert(ActiveBlocks, instance)
end