Bouncing box

I want to make a box come from off screen then bounce back and forth and then come settled down in the middle of the screen. It can be random bouning intervels or a set amount, it really does not matter. Does anyone think they can point me in the right direction?
Thank ya

Sure… make the box a movie clip, place it where you want it to start from, then add the following code to the outside of it.

onClipEvent(enterFrame){
xVelocity=this._x-200; //assuming that your movie is 400 across
xVelocity*=.94;
this._x+=xVelocity;
}

At least I think that will work. If not, just tell me and I’ll fix it. It may be that the numbers are reversed… I’m doing it from memory. :slight_smile:

it didnt bounce back and forth, it just went straight off the stage to the left really fast. I dunno

lol. I’ll work it out. I’m home now. Give me a minute or two.

you can try this. I find it to be a little choppy, but it works

onClipEvent(enterFrame){
diff=200-this._x;
velocity+=diff;
velocity*=.94;
_x+=velocity;
}

sweet man, thanks a bunch bro

You can just adjust it like as you wish:

onClipEvent(enterFrame){
  diff=200-this._x;
  velocity+=diff*.2;
  velocity*=.94;
  _x+=velocity;
}

And there’s a Springs tutorial too.

pom :slight_smile: