1

Currently, I have 2 images(barMiddle and blueBall1). The barMiddle can only move up and down by user response. And, it is in the middle of the screen. While, the blueBall1 will move and bounce around the screen. What I want to ask is how do I do image collision? I want the blueBall1 to bounce away when it hits barMiddle. I have heard something about Rectangle. However, does anyone know how to do it or do you have any other idea?

FYI: I am developing it for Windows Phone 8. Therefore, I was told by my lecturer that it is not encouraged to use XNA.

  • are you a friend a of gwenda ?? as she asked exact problem .. http://stackoverflow.com/questions/17333291/how-to-do-image-collision-in-c-sharp-for-windows-phone-8-using-windows-phone-app/17334754?noredirect=1#comment25150516_17334754 – Sandeep Chauhan Jun 28 '13 at 06:08

1 Answers1

0

for doing basic collision first calculate the distance between two objects(balls in you case) from the center of the each image. if this distance is less that or equal to the collision distance turn the second object in opposite direction.

loop
  • 9,002
  • 10
  • 40
  • 76
  • Is it possible for you to give me an example of it? – Elaine Harden Jun 28 '13 at 06:11
  • OK i got your problem. you have barmiddle which can move up and down so barmiddle x cordinate remain constant only its y points are changing. so first you have to calculate the distance between x coordinate of ball object and x coordinate of barmiddle Object.this distance has to checked with your checkcollisiondistance(which will be radius of your ball).Also you have to check that is y coordinate of your ball object is inbetween the lowest and highest y coordinate of the barmiddle object. – loop Jun 28 '13 at 06:34