0

Is there a function whereby I can provide co-ordinates (x,y) and retrieve whether or not a graphic or a bitmap exists at that coordinate on the view?

I am creating the game 'breakout' on android.

I have an array of bricks objects (that have their x/y positions) and a ball object (with its x/y position). I need to check if they collided.

John
  • 15,990
  • 10
  • 70
  • 110
user2316667
  • 5,444
  • 13
  • 49
  • 71
  • 2
    You should not try to determine if there is a bitmap at a certain position - think about it. The background of every view is a bitmap. It is possible (but complex, relatively slow and not necessary) to determine if a point is part of a brick but why can't you just compare the x,y of the ball with the x and ys of the bricks? Much simpler. – Simon Jun 04 '13 at 19:06
  • Just noticed your commend is identical to my answer... Upvoted yours – Cruceo Jun 04 '13 at 21:30

1 Answers1

1

Don't compare the bitmap as the background of every View is an image.

Instead, compare the x/y coordinates in your Brick / Ball Objects and determine if there is a collision based on those values.

Cruceo
  • 6,763
  • 2
  • 31
  • 52
  • That would require me to loop through every single pixel co-ordinate that every single block resides in... for(int i=y, i – user2316667 Jun 05 '13 at 02:08
  • Yes it would, but that's still a better approach than checking the actual background – Cruceo Jun 05 '13 at 18:06