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]