Hi,
I have a script I wrote where there are going to be multiple soldiers fighting, (represented by rectangles). In this example, one rectangle runs away, another one follows it.
Is this the most efficient way to write this? Can I use TweenLite for the follow part?
--------------
import com.greensock.TweenLite;
import com.greensock.easing.*;
//rect 1 runs away
TweenLite.to(object1, 4, {x:84, y:-160});
addEventListener(Event.ENTER_FRAME, loop);
//rect 2 follows rect 1
function loop(e:Event):void{
if(object1.x<object2.x){
object2.x-=10;
}else{
object2.x=object1.x;
}
if(object1.y<object2.y){
object2.y-=10;
}else{
object2.y=object1.y-32;
}
}