Hi all.
I have a MC (a ball) with this AS on it:
Code:
onClipEvent (load) {
left = 2 + _width / 2;
right = 498 - _width / 2;
top = 3 + _height / 2;
bottom = 285 - _height / 2;
xspeed = random(3) + 1;
yspeed = random(3) + 1;
}
onClipEvent (enterFrame) {
_x = _x + xspeed;
_y = _y + yspeed;
if ( (_x <= left) or (_x >= right) ) {
xspeed *= -1;
}
if ( (_y <= top) or (_y >= bottom) ) {
yspeed *= -1;
}
}
This bounces the ball off each 'wall'. Can anybody tell me how to add more balls (using actionscript - ie not copying and pasting on the stage) and to make the balls bounce off eachother too?
Thanks.