How do I add an event listener for an object from an array?
I wan’t a collision event to happen for the object.
[lua]local function spawnCoinz()
local coine = {}
for i = 1, 40, 1 do
coinss = display.newImage(“Coin2.png”)
coine[i] = coinss
coinss.x = 150
coinss.y = 100
end
physics.addBody( coine[1], { density = 3.0; friction=0.5; bounce = 0.3 } )
physics.addBody( coine[2], { density = 3.0; friction=0.5; bounce = 0.3 } )
end
coine[1].collision = onLocalCollision
coine[1]:addEventListener( “collision”, coine )
–Debugger says coine is a nil value
–How do I make it so I can access the object of the array and create an event listener for it? Thanks. [import]uid: 54001 topic_id: 9597 reply_id: 309597[/import]
