Hi Blickon
I dont know if there a better way, but I do this…
You have to create a function, lets say “animate”, this function will ask for the boundaries x and y positions and then changes the orientation of the object (basically adding 1 to move to the right adding -1 to move to the left)
Here is my example
local increment =1 – Add 1 to x coordinate, to move right, Add -1 to x coordinate to move left
local xbound_right = 300 – The maximun value for x coordinate at right
local xbound_left = 200 – The minimum value for x coordinate at left
function animate (event)
if object.x > xbound_right then
increment = -1
end
if object.x < xbound_left then
increment = 1
end
object.x = object.x + increment
end
– Now add a listener to update the animation
Runtime:addEventListener( “enterFrame”, animate );
This code will move the “object” between 200 and 300 coordinates. Maybe there another ways to do it, but this works for me.
Good Luck.
Best Regards!!!
Jose [import]uid: 84893 topic_id: 22755 reply_id: 90869[/import]