Carlos has an article on line about moving along bezier curve
http://www.carlosicaza.com/2011/04/23/moving-an-object-along-a-bezier-curve-part-i/
it is a very good article and the code is very helpful and allows the object to move along the curve in a smooth manner. Most of the process I understand; just some of the math I am a little unsure of. What I have not been able to do, using that existing code, is control the overall speed of the object. When I run the code Carlos supplied it runs smooth but at a specific speed I cannot change.
I want to be able to reduce that overall speed and have the object move slower and still be smooth. Various thing I have tried creates a rather jerky movement.
Does anyone have any insight/knowledge on how to control the overall speed of the object as it traverses the curve??? Below is the key the function that handles the movement of the object. It is called by enterFrame event.
local function moveAlongThesegment( inc )
if (bFirst == true ) then
plane = display.newImage(“f15.png”,-100,-100);
prevX = bezierSegment[1].x;
prevY = bezierSegment[1].y;
bFirst = false;
return;
end
local p = {};
p.x = bezierSegment[inc].x;
p.y = bezierSegment[inc].y;
local angle = math.atan2( p.y - prevY, p.x - prevX)
angle = angle * 180 / PIE
plane.x = p.x;
plane.y = p.y;
plane:rotate(angle-prevAngle);
prevAngle = angle;
prevY = p.y;
prevX = p.x;
end
Thanks [import]uid: 148857 topic_id: 26563 reply_id: 326563[/import]