Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Trusted Contributor
Posts: 177
Registered: ‎03-02-2010
My Device: Not Specified

How redirect ball when hit on brick?

[ Edited ]



how i redirect a ball when it hit on bricks on all edge (top,bottom,right left) in brick breaker game.


please refer some code if possible. i draw bricks and ball using XYrect and paint method.


i am used following code but some time it not work and ball does not redirect on right way.

            boolean movelt = brickrect.contains(ballRect.x, ballRect.y);
            boolean movert = brickrect.contains(ballRect.X2(),ballRect.y);
            boolean rightln = brickrect.contains(ballRect.x, ballRect.Y2());
            boolean leftln = brickrect.contains(ballRect.X2(), ballRect.Y2());

             if (rightln && leftln) {
                goingDown = false;
             else if (!rightln && !leftln) {
                goingDown = true;
             else if (movelt || rightln) {
                goingRight = true;
             else if(movert || leftln){
                goingRight = false;



please give me some code for this and please let me know  if i am doing wrong


Please use plain text.