[font=Arial]I modified the falling snow to move upwards to make bubbles, but now I want them to come from a specific spot from movie clip which is moving constantly and roating. They also have to stay within the bounds of the water.
I tried placing it on the spot I want on the movie clip, and alter the code like so:
onClipEvent (load) {
//variables that will modify the rising bubbles
i = 1+Math.random()*2;
k = -Math.PI+Math.random()*Math.PI;
//giving each bubble unique characteristics
this._xscale = this._yscale=50+Math.random()*100;
this._alpha = 75+Math.random()*100;
}
onClipEvent (enterFrame) {
//putting it all together
rad += (k/180)*Math.PI;
this._x -= Math.cos(rad);
this._y -= i;
if (this._y<=_root.waterLevel) {
//go to the clip which duplicates the bubbles
this._y = _parent._y;
this._x = _parent._x;
}
if ((this._x>=555) || (this._x<=45)) {
this._y = _parent._y;
this._x = _parent._x;
}
}
But with that, the bubble clip ends up 100 pixels behind where i placed it, and theres no movement or duplication. :h:
[/font]
I hate when I make a forum post and figure part of it out on my own…
I broke the first rule: the movie clip has to be at 0,0 for it work properly
To properly place the bubbles however, I first find the difference in coordinates between the target and what im placing, then instead of
this._y = _parent._y;
I change them to
this._y = _root.target._y + dy
where dy is target._y - location._y;
But that’s the easy part. Here is the tricky part:
That doesn’t factor in the rotation! (dun dun dun)
The target is rotating at:
Math.sin(timenow+.9)*2;
where timenow is the milliseconds converted into seconds.
So, how does the rotation effect dx and dy? (My trig is rusty )
----EDIT-----
Ok! I’ll answer my own question again before somsone can point me to this tuitorial
Using my dx and dy, I need to find the hypotenuse of an imaginary right triangle, the hypotenuse is the line beginning from the target._x and _y and stretching to my location._x and _y. Then… I rotate it by the same rotation and convert back to dx and dy, and I do all of this using mathmatics. None of which I can do. I’ll go study now.