Hello fellow game makers…
So far I have code that when you click and drag an image it replaces it with another image. Everything seems to work great until I move the object over another object… That object gets removed. 
Here is the code:
[lua]–[[
PROJECT OBJECTIVES
OBJECTIVE 1:
Pick weeds and make them appear to be uprooted.
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 weedTable = {}
local unrootTable = {}
local t1 = {
{ x = 650, y = 365 },
{ x = 350, y = 380 },
{ x = 550, 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
for i=1, 5 do
local unrootWeed = display.newImageRect(“picked.png”, 236, 221)
unrootTable[i] = unrootWeed
–unrootTable[i]:setFillColor(255,255,0)
unrootTable[i].isVisible = false
end
local function drag_unroot(event)
if event.phase == “moved” then
event.target.x = event.x
event.target.y = event.y
end
end
local function drag_weed(event)
local id = event.target.id
if event.phase == “moved” then
print(id)
event.target.x = event.x
event.target.y = event.y
event.target:removeSelf()
event.target = nil
weedTable[id].isVisible = false
unrootTable[id].isVisible = true
unrootTable[id].x = event.x
unrootTable[id].y = event.y
unrootTable[id]:addEventListener(“touch”, drag_unroot)
end
return true
end
for i=1,5 do
local weed = display.newImageRect(“weed.png”, 200, 150 )
weedTable[i] = weed
weedTable[i].id = i
weedTable[i].x = t1[i].x;
weedTable[i].y = t1[i].y;
weedTable[i]:addEventListener(“touch”, drag_weed)
print(weedTable[i].id)
end[/lua]
Thanks for any help finding this nasty little glitch!! [import]uid: 51459 topic_id: 17183 reply_id: 317183[/import]