I looked over:
https://coronalabs.com/blog/2011/09/29/tutorial-modular-classes-in-corona/
In order to learn about Lua and Object Oriented Programming.
However I came across a peculiar problem. So I created the class brick and wanted to add a function within the brick so that if it’s hit it could delete itself. This whole setup is causing all sorts of problems and I wasnt sure if I was even going about it right.
Question: How do I add collision filters within an object.
function brick.new( x, y, name, ageInYears ) -- constructor local newbrick = { name = name or "Unnamed", age = ageInYears or 2, body = display.newImageRect( "brick.png", 100, 50 ), } newbrick.body.x = x newbrick.body.y = y physics.addBody( newbrick.body, "static", { friction=0.5, bounce=0.3 } ) local function onLocalPostCollision( self, event ) self:rollOver() end newbrick.body.postCollision = onLocalPostCollision newbrick.body:addEventListener( "postCollision" ) return setmetatable( newbrick, brick\_mt ) end function brick:hit() print(self.name) display.remove(self.body) end