If you want to connect the ball with the word animate when you drag a path to it…Like in “Martain Controls” use this code -->
[lua]local maxPoints = 2
local lineThickness = 5
local endPoints = {}
local path = {}
local i =1
local traced = 1
local animate
local posCount = 1
–create a circle ball
local ball = display.newCircle( 150, 150, 15 )
local function drawLine(event)
if event.phase == “began” then
for i=1, traced, 1 do
table.remove (path ,i)
end
i = 1
traced = 1
elseif event.phase == “moved” then
table.insert(endPoints, 1, {x = event.x, y = event.y, line= nil})
path[i] = {}
path[i].x = event.x
path[i].y = event.y
i=i+1
traced = traced + 1
if(#endPoints > maxPoints) then
table.remove(endPoints)
end
for i,v in ipairs(endPoints) do
local line = display.newLine(v.x, v.y, event.x, event.y)
line:setColor( 255, 255, 255, 255 )
line.width = lineThickness
end
elseif(event.phase == “ended”) then
while(#endPoints > 0) do
table.remove(endPoints)
end
end
end
Runtime:addEventListener(“touch”, drawLine)
–moving the object – this is where animation takes place
local function moveObject(event)
if posCount < traced then
ball.x = path[posCount].x
ball.y = path[posCount].y
posCount = posCount + 1
else
if animate then
timer.cancel(animate)
end
end
end
function anim()
animate = timer.performWithDelay( 10, moveObject, traced )
end
– to move ball when we click the animate text
local function move(event)
if(event.phase == “ended”) then
posCount = 1
transition.to(ball, { time = 500, x= path[1].x, y =path[1].y, onComplete= anim})
end
return true
end
–create a text which when clicked will animate the object
local text = display.newText( “Animate!”, 220, 50, nil, 40 )
text:addEventListener(“touch”, move)[/lua] [import]uid: 51459 topic_id: 14114 reply_id: 52159[/import]