Jump to content
Search Community

soldiers fighting animation question

dgimness test
Moderator Tag

Recommended Posts

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;

    }

}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...