I’m having a hard time implementing OOP with an eventListeners. I don’t know where to place my eventListener. I get an error saying assertion failed. It’s pointing out the eventListener I declaired. Here is a sample of my code.
[lua]
–main.lua
local shape = require"shape"
local shape1 = shape.new( “Square”, 4, 40, 40, 40, 40 )
local shape2 = shape.new( “box”, 1, 120, 240, 40, 40 )
[/lua]
[lua]
–shape.lua
local shape = {}
local shape_mt = { __index = shape }
local function showStat(name)
print("The shape is: " … name)
end
function shape.new( name, x1, y1, x2, y2 )
local newShape = {}
newShape.Object = display.newRoundedRect(x1, y1, x2, y2, 1)
newShape.name = name
newShape.Object:addEventListener(“tap”, showStat(name));
return setmetatable( newShape, shape_mt )
end
return shape
[/lua]
I’m just starting to learn implementing OOP on corona, so I’m having some problems right now. Can anyone help me how to properly use OOP on corona? Thanks…