Everything was lookin easy until you said that bubbles can’t be on top of eachother. Now you’re looking at checking the location of all these bubbles and comparing each to the location of every other bubble.
This will make your bubbles sloooowwwww… it is, of course, entirely doable.
what should I do when I want them to go only till the border of the MC i will place them in (which is not the border of the actual main.SWF)
instead of simply disappearing, i would like em to fade to alpha 0%… how would I do that?
[script]
onClipEvent (load) {
a = 0;
i = 0;
// randomizes the x-motion and y-motion (for the y, how
// fast it moves up, for x, how far back and forth the
// bubble moves.
xMove = random(100)+1;
yMove = random(10)+1;
// size = random(100)/100;
if (_name == “bubbles”) {
_visible = false;
}
}
onClipEvent (enterFrame) {
// the script for all the movieclips except the main one.
if (_name != “bubbles”) {
// this makes the bubbles move back and forth and
// centers the motion.
_x = Math.sin(a)*xMove+400;
// this moves it up
_y -= yMove;
// this increments what goes into the Sine function
// above which makes the values go back and forth,
// which is what you see when the bubbles are moving.
// if you have a graphing calculator, graph y=sin(x)
// and you’ll see what i mean.
a += 0.1;
if (this._y<0) {
// once is goes offscreen, take it out
this.removeMovieClip();
}
} else {
// the script for the main clip
// (what you see on the stage)
++i;
// this makes the bubbles
duplicateMovieClip (this, “bub”+i, i);
// limiter, there can only be 75 bubbles on the screen
// at once (processor saver)
if (i == 75) {
// resets counter so the bubble in layer 0, if it’s
// still on the screen gets replaced, so disappears
i = 0;
}
// randomizes the size
size = random(100)/100;
_parent[“bub”+i]._width *= size;
_parent[“bub”+i]._height *= size;
}
}
It can kinda be done with hitTest, but it’s the same idea there, you will have to hitTest each bubble against every other bubble.
To make it fade out - make the bubble an MC with the first frame a normal bubble, then the next 20 or so (whatever you want) frames are the tween out to 0 alpha. Then tell the MC that it should play() when it get’s to a certain _y.
hmmm, yes, but this would result in all bubbles fading out at the exact same height… while then I would prefer that it would fade out more randomly… if that is possible…
but code-wise, how would that be done… and wouldn’t that imply that the code would have to loop?