user3221346
user3221346

Reputation: 11

Corona SDK addEventListener

Is anyone could help to sort out this Error?

AddEventListener has a problem to called function...

--ship as a custom attribute with the value of false
    rects[i][j].ship = false
--Add an event listener to get tappedRect called
    rects:addEventListener("tap" ,tappedRect)
    end

end
--TappedRect function use when a rectangle gets tapped on

function tappedRect(event)
        if event.target.ship then
           event.target.ship = true
           event.target:setFillColor(0, 255, 0)
        else
           event.target = false
           event.target:setFillColor(255, 0, 0)
        end
end

Upvotes: 1

Views: 312

Answers (1)

Fabio
Fabio

Reputation: 3067

in corona you can only add an event listener that calls a method after that method is defined (you have to call addEventListener after defining tappedRect)

Upvotes: 1

Related Questions