new developer here i could really use some help.
i have this code i have been using with multi touch works just fine when i drag it however when i tap it
it goes to the snap position.
I would like it only to react when dragged not sure what i need to change.
i have this code copied 7 times for seven different letters only one out of the seven snap the others return back.
like i said before it works fine if i drag but not when it is taped.
[lua]
-THIS IS THE CORRECT ANSWER
– Circle outline
circLine = display.newImageRect(“images/A.png”, 100, 100);
circLine.x = display.contentCenterX
circLine.y = display.contentCenterY-42
circLine.alpha=0.01
– circle positioning
Agoodbutton = display.newImageRect(“images/A.png”, 100, 100);
Agoodbutton.x = display.contentCenterX+101
Agoodbutton.y = display.contentHeight-20
Agoodbutton.alpha=0.01
Agoodbutton:scale(.3, .3)
– Circle
MultiTouch.activate(Agoodbutton, “move”, “single”);
– Set initial variables to 0
local AgoodbuttonPosX = 0;
local AgoodbuttonPosY = 0;
– User drag interaction on blue circle
local function circleDrag (event)
local t = event.target
Agoodbutton.alpha = 1
transition.to(Agoodbutton, {time=210, xScale = .6, yScale = .8})
–If user touches & drags circle, follow the user’s touch
if event.phase == “moved” then
AgoodbuttonPosX = Agoodbutton.x - circLine.x;
AgoodbuttonPosY = Agoodbutton.y - circLine.y;
if (AgoodbuttonPosX < 0) then
AgoodbuttonPosX = AgoodbuttonPosX * -1;
end
if (AgoodbuttonPosY < 0) then
AgoodbuttonPosY = AgoodbuttonPosY * -1;
end
– If user drags circle within 50 pixels of center of outline, snap into middle
if (AgoodbuttonPosX <= 25) and (AgoodbuttonPosY <= 25) then
Agoodbutton.x = circLine.x;
Agoodbutton.y = circLine.y;
end
– When the stops dragging circle within 50 pixels of center of outline, snap into middle, and…
elseif event.phase == “ended” then
if (AgoodbuttonPosX <= 25) and (AgoodbuttonPosY <= 25) then
Agoodbutton.x = circLine.x;
Agoodbutton.y = circLine.y;
– …lock circle into place where it cannot be moved.
MultiTouch.deactivate(Agoodbutton);
elseif (AgoodbuttonPosX >= 0.1) and (AgoodbuttonPosY >= 0.1) then
–Agoodbutton.x = Abutton.x;
–Agoodbutton.y = Abutton.y;
transition.to(Agoodbutton, {time=500, x=display.contentCenterX+101, y=display.contentHeight-20, alpha=0.01, xScale = .3, yScale = .3})
– …lock circle into place where it cannot be moved.
else
print(“no hagas nada”)
end[/lua]
thanks for your help.