I’m having problems with my flash game, i am making slimeball and im using the hitTest to make my ball bounce off of the players, but because my players are semi circular when it hits off the back of my player the ball still goes forward when it should bounce off the player in the direction that it came from, if that makes sense
Somebody please help! I’ve attached my code so you can look at it, all of my code is on the ball.
my code:
onClipEvent (load) {
xspeed = 20;
yspeed = 20;
}
onClipEvent (enterFrame) {
if (this._y<0 || this._y>275.3) {
yspeed *= -1;
}
if (this._x< 0 || this._x >640) {
xspeed *= -1;
_root.ball_mc._x += xspeed;
}
if (_root.ball_mc.hitTest(_root.net_mc)) {
trace("ouch");
xspeed *= -1;
}
if (_root.ball_mc.hitTest(_root.player2_mc)) {
trace("Yay");
xspeed *= -1;
yspeed *= -1;
this._x += xspeed;
this._y -= yspeed;
}
if (_root.ball_mc.hitTest(_root.player1_mc)) {
trace("work");
xspeed *= -1;
yspeed *= -1;
this._x += xspeed;
this._y -= yspeed;
}
this._x += xspeed;
this._y -= yspeed;
if (_root.ball_mc.hitTest(_root.block1_mc)) {
_root.score1_mc.gotoAndStop(2);
}
}