Hi,
I just started developing with Corona and I’m playing around with the Pool sample. I wanted to add a trail for the ball. I wanted to show the trail at same distance. I used the code below and when I look at the terminal for the distance, I have:
26.381780244754
23.276529923797
20.357230967924
19.16005247002
18.033290996604
16.972780578566
15.974674244755
15.035195993872
18.680639743354
16.897055342822
16.441087332779
16.824556587451
16.528801885102
15.665359955877
15.654783493663
15.497504230838
15.112433524753
15.031581187523
15.020930423823
…
Maybe someone can give a different solution? Thx
[code]
– Code located at CueShot even at ENDED phase
– START TRAILING DOTS BLOCK
local i
– First, delete previous trail
for i = trailGroup.numChildren,1,-1 do
local child = trailGroup[i]
child.parent:remove( child )
child = nil
end
local prevLocX = 0
local prevLocY = 0
local startDotCreation = function()
local createDot = function()
local dX = math.abs(prevLocX - t.x )
local dY = math.abs(prevLocY - t.y)
local distance = math.sqrt((dX*dX)+(dY*dY))
if (distance > 15) then
print( distance )
trailDot = display.newCircle( view, t.x, t.y, 3 )
trailDot:setFillColor( 255, 255, 255, 255 )
trailDot.alpha = 0.3
trailDot:toBack()
trailGroup:insert( trailDot )
prevLocX = t.x
prevLocY = t.y
end
end
dotTimer = timer.performWithDelay(5, createDot, 250 )
end
startDotCreation()
– END TRAILING DOTS BLOCK
[/code] [import]uid: 161653 topic_id: 30879 reply_id: 330879[/import]
Will try to find more information about how to implement this. Cheers [import]uid: 161653 topic_id: 30879 reply_id: 123566[/import]