PDA

View Full Version : bouncing box



buddylee
October 24th, 2002, 11:45 PM
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

upuaut
October 25th, 2002, 12:39 AM
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. :)

buddylee
October 25th, 2002, 11:03 AM
it didnt bounce back and forth, it just went straight off the stage to the left really fast. I dunno

upuaut
October 25th, 2002, 11:16 AM
lol. I'll work it out. I'm home now. Give me a minute or two.

upuaut
October 25th, 2002, 11:38 AM
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;
}

buddylee
October 25th, 2002, 11:40 AM
sweet man, thanks a bunch bro

pom
October 25th, 2002, 01:44 PM
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 :)