attempt to index global "tappedRect" (a nil value)

function tappedRect:touch(event)

if (boxSize:setFillColor(255,255,255)) then

    boxSize:setFillColor(0,255,0)

    end

end

boxSize:addEventListener(“touch”, tappedRect)

I don’t know why but it won’t work with a grid I have made, but it does work on a single rectangle in a seperate programme.

i may be wrong but i dont think setFillColor is readable. all the code above does is verify that boxSize has a setFillColor function

You are halfway between a function based handler and an table based handler:

Function based (my preferred way)

local function doSomething( event )     -- do stuff end   object:addEventListener("touch", doSomething)

vs.

function:object:touch(event)      -- do stuff end object:addEventListener("touch", object)

You can’t intermingle them.

Rob

i may be wrong but i dont think setFillColor is readable. all the code above does is verify that boxSize has a setFillColor function

You are halfway between a function based handler and an table based handler:

Function based (my preferred way)

local function doSomething( event )     -- do stuff end   object:addEventListener("touch", doSomething)

vs.

function:object:touch(event)      -- do stuff end object:addEventListener("touch", object)

You can’t intermingle them.

Rob