In my project I was able to set up a for loop to tell some images to go in t1 table of x and y cords…
I followed what was done in this link for reference:
http://developer.anscamobile.com/code/tables-lua-dictionaries-and-arrays
You can see my code here:
[lua]–[[
PROJECT OBJECTIVES
OBJECTIVE 1:
Slash weeds and make them appear to be choped up.
OBJECTIVE 2:
Spreed good seeds to grow
OBJECTIVE 3:
Water plants and watch them grow
]]
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
print(“objects”… tapped)
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]
Can anybody show me how to print a statement telling me which objects have been touched… Thanks!!
[import]uid: 51459 topic_id: 16962 reply_id: 316962[/import]