I am trying to reverse this at a random vx when it reaches one side of the movie. Then when it reaches the other side it reverses the vx again at a random vx.
////////////////////////////////////////////////////////////
[COLOR=red]
spdText.damp = .95;
centerx = 4.3;
leftside = -258;
spdText.vx = Math.random()*8+6;
spdText.onEnterFrame = TextMove;
function TextMove() {
this._x += this.vx;
if (this._x>318) {
this._x = 318;
this.vx -=Math.random()*8+6;
}
if (this._x<leftside) {
this._x = leftside;
this.vx +=Math.random()*8+6;
}
this.vx *= this.damp;
this.vy *= this.damp;
}
[/COLOR]
///////////////////////////////////////////////////////////////
right now it gets to the right side but it won’t reverse the vx
not sure exactly what thats supposed to mean but Ill assume it something similar to the 318 which is I guess the rightside? From what I gather I think you want something like this:
so what this is doing is checking to see if spdText reached either the right side of the left side, and if so, reversing the direction. IF you reach the left side, the new direction (vx) should be positive to move it right, if reaching the left side, the new vx should be negative. And thats fully negative, not just subtracting using -=.