Reference point Setting

How can i set the reference point of different items of the tables so that when i drag them to that region it gets fixed ?Basically what i want is I have 3 images in my table.Now what i what i want is if i drag the image to the specified region or location then it should fix there .Here is the following what i have done till now…
Please help me out as i am unable to recognize how to do that?

[lua]local arguments ={}
arguments[“atta1”]=display.newImage(“btn1.png”)
arguments[“atta1”].x=100
arguments[“atta1”].y=100

arguments[“atta2”]=display.newImage(“btn2.png”)
arguments[“atta2”].x=100
arguments[“atta2”].y=250

arguments[“atta3”]=display.newImage(“btn3.png”)
arguments[“atta3”].x=100
arguments[“atta3”].y=400

local function onTouch( event )
local t = event.target

local phase = event.phase
if “began” == phase then

local parent = t.parent
parent:insert( t )
display.getCurrentStage():setFocus( t )
t.isFocus = true

t.x0 =t.x
t.y0 = t.y
elseif t.isFocus then
if “moved” == phase then

t.x=event.x
t.y=event.y
elseif “ended” == phase or “cancelled” == phase then
if event.target==arguments[“atta1”] then
print(“I am in RED”)
t.x=100
t.y=100
display.getCurrentStage():setFocus( nil )
t.isFocus = false
elseif event.target==arguments[“atta2”]then
print(“I am in BLUE”)
t.x=100
t.y=250
display.getCurrentStage():setFocus( nil )
t.isFocus = false
else

print(“I am in NOWHERE”)
t.x=t.x0
t.y=t.y0
display.getCurrentStage():setFocus( nil )
t.isFocus = false
end
end
end
return true
end

arguments[“atta1”]:addEventListener( “touch”, onTouch )
arguments[“atta2”]:addEventListener( “touch”, onTouch )
arguments[“atta3”]:addEventListener( “touch”, onTouch )[/lua] [import]uid: 99780 topic_id: 18863 reply_id: 318863[/import]

you need to set runtime function and flag for it to work, i’ve done it before
in runtime function check for a position of each element in table(for loop) and if that positions it the borders of your zone then some amount of health or other matter adding\happening to that element\s [import]uid: 16142 topic_id: 18863 reply_id: 72664[/import]

Ya i have got what you wanted me to understand but could you provide me with an example or cite an example code to understand me better…Please help me as I have been in trouble regarding this for a long time… [import]uid: 99780 topic_id: 18863 reply_id: 72675[/import]

no problem, i still got that file left)

plug and play and see how its done
[lua]display.setStatusBar( display.HiddenStatusBar ) – HIDE STATUS BAR

local enemyTable = {}

local function touch (event)
if event.phase == “began” then
event.target.isFocus = true
event.target:toFront()
event.target.bar:toFront()
elseif event.phase == “moved” and event.target.isFocus == true then
event.target.x = event.x
event.target.y = event.y
event.target.bar.x = event.target.x - 15
event.target.bar.y = event.target.y - 30
event.target.bar.txt.x = event.target.bar.x
event.target.bar.txt.y = event.target.bar.y - 20
elseif event.phase == “ended” or event.phase == “cancelled” then
event.target.isFocus = false
end
return true
end

enemyTable[1] = display.newRect(0,0,50,50)
enemyTable[2] = display.newRect(0,0,50,50)
enemyTable[2]:setFillColor(255,0,0)
enemyTable[3] = display.newRect(0,0,50,50)
enemyTable[3]:setFillColor(0,255,0)
for i=1,3 do

enemyTable[i].x = math.random(50,300)
enemyTable[i].y = math.random(50,300)
enemyTable[i].health = 10
enemyTable[i].name = “enemy”…i

healthbar = display.newRect(0,0,enemyTable[i].width,4)
healthbar:setFillColor(255,0,0)
healthbar:setReferencePoint(display.TopLeftReferencePoint)
healthbar.x = enemyTable[i].x - 15
healthbar.y = enemyTable[i].y - 30
healthbar.xScale = 0.1
healthbar.txt = display.newText("",0,0,nil, 20)
healthbar.txt.text = enemyTable[i].health
healthbar.txt.x = healthbar.x
healthbar.txt.y = healthbar.y - 20
enemyTable[i].bar = healthbar

enemyTable[i]:addEventListener(“touch”, touch)

end

local repairZone = display.newRect(0,0,100,100)
repairZone.x = 100
repairZone.y = 400

local function check_and_repair()

for i,v in pairs(enemyTable) do

if enemyTable[i].x > repairZone.x - 50 then

if enemyTable[i].y > repairZone.y - 50 and enemyTable[i].y < repairZone.y + 50 then

if enemyTable[i].health < 100 then
enemyTable[i].health = enemyTable[i].health + 1
print(enemyTable[i].health)
enemyTable[i].bar.txt.text = math.floor(enemyTable[i].health)
end
end
end

if math.floor(enemyTable[i].health) > 30 then
enemyTable[i].bar.xScale = 0.3
enemyTable[i].bar:setFillColor(255,0,0)
end
if math.floor(enemyTable[i].health) > 50 then
enemyTable[i].bar.xScale = 0.5
enemyTable[i].bar:setFillColor(180,180,0)
end
if math.floor(enemyTable[i].health) > 80 then
enemyTable[i].bar.xScale = 0.8
enemyTable[i].bar:setFillColor(0,255,0)
end
if math.floor(enemyTable[i].health) >= 100 then
enemyTable[i].bar.xScale = 1
enemyTable[i].bar:setFillColor(0,255,0)

end

end

for i,v in pairs(enemyTable) do
if enemyTable[1].health == 100 and enemyTable[2].health == 100 and enemyTable[3].health == 100 then
for i=1,#enemyTable do
–Runtime:removeEventListener(“enterFrame”, check_and_repair)
enemyTable[i].bar.txt.text = “WIN”
end
end
end
return true
end

Runtime:addEventListener(“enterFrame”, check_and_repair)[/lua] [import]uid: 16142 topic_id: 18863 reply_id: 72676[/import]