3

I try to do homework, and I write breakout game. Now,I write the basic function of this game finish.but I want to increase Bonus When ball crash the bonusbricks,I write method to check them and get the color form object that ball crash.

} else if(color == Color.BLACK){ 
        double xBonus = ball.getX() +20;
        double yBonus = ball.getY() +20;
        remove(ball);
        ball = new GOval(xBonus, yBonus, BALL_RADIUS+20, BALL_RADIUS+20);
        ball.setFilled(true);
        ball.setFillColor(Color.RED);
        add(ball);

GObject collider = getCollidingObject(); I use collider to detect the object that ball crash but when the ball crash the bonus brick. The ball has increase size but collider is detect new ball object to be the bricks and bounce ball though game edge. Please help me .. Sorry,for my wrong grammatically.

Mat
  • 202,337
  • 40
  • 393
  • 406
DrNutsu
  • 475
  • 2
  • 10
  • 21
  • Is the problem that the ball it is going outside edges when you redraw but it fine afterwards, or is the problem that the bigger ball always crosses edges when it bounces around? – Windle Jul 18 '12 at 14:37
  • the Collider detect the bigger ball as the new object, it always bounce himself until out of edges.I don't know why?? – DrNutsu Aug 06 '12 at 01:38

1 Answers1

0

I believe you want to use * 20 on your ball.getX and ball.getY assignments.

It sounds like the new ball object is not in the same instance as the original game panel. You should make sure you are accepting the new ball object in the same instance on the panel that the game is played.

If you show some more of your code I may be able to be more specific.

Robert
  • 4,306
  • 11
  • 45
  • 95