I have the following situation that i couldn’t move on yet. Hope somebody can bring some clear ideas.
I need to move an object from point A to D, stopping in points B, C first. So, I have a table with all end points (x and y) and I am looping the .x and .y positions. The issue is I cannot control the duration of the movement. I would like to say, from point A to D, it will take 5 seconds.
Anyways, this is my current code:
xisis = { 610,503,621,601,493,454,610,503,621,601,493,454 }
yisis = { 891,687,637,432,356,521,891,687,637,432,356,521 }
bee = display.newImageRect( "bee.png", 26, 28 );
bee.x = 610; bee.y = 891; bee.alpha = 1
local sec = 5 --5 seconds or the animation duration
local msec = sec / (#xcoords - 0) --duration divided by the number of points
local coordCount = 1
local function moveObject()
if coordCount \<= #xcoords then
bee.x = xisis[coordCount]
bee.y = yisis[coordCount]
coordCount = coordCount + 1
--I tried a timer to wait "msec" but it didn't pause the loop
--I tried a gtween transition with the same results of the timer
else
Runtime:removeEventListener( "enterFrame", moveObject )
end
end
Runtime:addEventListener( "enterFrame", moveObject )
As you can see in the comments:
–I tried a timer to wait “msec” but it didn’t pause the loop
–I tried a gtween transition with the same results of the timer
Thanks!
[import]uid: 4883 topic_id: 13752 reply_id: 313752[/import]