@ crssmn
How can I apply this chunk of code
[lua] local img = display.newImage( “ball01.png” )
img.x = 100; img.y = 200
function rectlistener()
img:removeSelf()
img = display.newImage( “avoid01.png” )
img.x = 100; img.y = 200
end
img:addEventListener(“touch”, rectlistener )[/lua]
To an image I have created in a table. So when I touch the images in the table they turn into another image entirely… Heres the code I am working with
[lua]display.setStatusBar( display.HiddenStatusBar ) – HIDE STATUS BAR
local loqsprite = require(‘loq_sprite’)
math.randomseed(os.time())
math.random()
local _W = display.contentWidth
local _H = display.contentHeight
local objects = {}
local speed = 5
local i
local x0 , y0, x1, x2
local t1 = {
{ x = 650, y = 365 },
{ x = 350, y = 380 },
{ x = 600, y = 480 },
{ x = 400, y = 550 },
{ x = 700, y = 600 },
}
local background = display.newImageRect(“background.png”, 1024, 768)
background.x = _W/2; background.y = _H/2
function tapped(event)
event.target:removeEventListener(“tap”, tapped)
event.target:removeSelf()
objects[event.target] = nil
end
for i = 1,5 do
objects[i] = display.newImageRect(“weed.png”, 200, 150 )
objects[i].x = t1[i].x; objects[i].y = t1[i].y
objects[i]:addEventListener(“tap”, tapped)
end[/lua]
THANKS FOR ANY HELP!! [import]uid: 51459 topic_id: 5174 reply_id: 63615[/import]