Flash actionscript 3.0: circle collusion in AS2.0

circle collusion in AS2.0

Posted by Sankar.G | Posted in | Posted on 4:45 PM

CIRCLE COLLUSION IN AS2.0
ang = 1;
speed = 0.3;
r = 100;
moved();
c2.onPress = function() {
startDrag(this);
};
c2.onRelease = function() {
stopDrag();
};
start_btn.onPress = function() {
c2._x = _xmouse;
c2._y = _ymouse;
};
function moved() {
this.onEnterFrame = function() {
c1._x = 200+(Math.sin(ang)*r);
ang += speed;
xdist = c2._x-c1._x;
ydist = c2._y-c1._y;
dist = Math.sqrt(xdist*xdist+ydist*ydist);
angle = Math.atan2(ydist, xdist);
if (dist<
c1._width) {
c2._x = c1._x+(c1._width*Math.cos(angle));
c2._y = c1._y+(c1._width*Math.sin(angle));
updateAfterEvent();
}
};
}

Comments (0)