View Full Version : random.... teddy bear movement!
liam
June 10th, 2003, 01:04 AM
at vmkdsn.com (http://www.vmkdsn.com)!
you see what i've had to resort to since the random splash thing didn't fly??? haha...
liam
June 10th, 2003, 01:10 AM
oh, and in case you're interested:
set up a bounding box (rectangular movie clip) on your stage where you want the teddies to mosh around in.
then, on a frame of the root timeline, set up the coordinates of the bounding box with (where boundingBox_mc is its instance name):
// define boundingBox's coordinates
boundLeft = boundingBox_mc._x;
boundRight = boundingBox_mc._x+boundingBox_mc._width;
boundTop = boundingBox_mc._y;
boundBottom = boundingBox_mc._y+boundingBox_mc._height;
then on the first frame of your bear movie clip:
// start jumping
randomMove = 50;
this.onEnterFrame = function(){
//init xpos movements
newXpos = this._x+(random(randomMove)-(randomMove/2));
curXpos = this._x;
if(curXpos<=_root.boundLeft){
newXpos += random(randomMove);
}else{
if(curXpos>=_root.boundRight){
newXpos += -(random(randomMove));
}
}
//init ypos movements
newYpos = this._y+(random(randomMove)-(randomMove/2));
curYpos = this._y;
if(curYpos<=_root.boundTop){
newYpos += random(randomMove);
}else{
if(curYpos>=_root.boundBottom){
newYpos += -(random(randomMove));
}
}
// start moving
this._x = newXpos;
this._y = newYpos;
}
mosh, teddies, mosh.
thoriphes
June 10th, 2003, 01:11 AM
hehe, but why you chose teddy bears is beyond me.
liam
June 10th, 2003, 02:25 AM
lol... it's my style :P
morse
June 10th, 2003, 02:29 AM
sezier
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.