I am using this code to add several pictures and add touch listener to them. It works fine when there is no “][1]” but when using a table as image display it doesnt work anymore. As there are 30 pictures I dont want to add them one by one rather add or using myBall{} table.
myBall={} myBall[1] = display.newImage( "letters/a.jpg", 150,150) myBall[1].xScale = 0.5 myBall[1].yScale = 0.5 function myBall[1]:touch( event ) if event.phase == "began" then if touched == false then end -- set touch focus display.getCurrentStage():setFocus( self ) self.isFocus = true elseif self.isFocus then if event.phase == "moved" then myBall[1].x = event.x myBall[1].y = event.y elseif event.phase == "ended" or event.phase == "cancelled" then -- reset touch focus display.getCurrentStage():setFocus( nil ) self.isFocus = nil end end return true end myBall[1]:addEventListener( "touch" )