0

i have a question about android games.I cant make a collision between 2 objects.The rectangle collision seems work perfect in java but in android is not. I am using the intersect method to check collision.If you guys have some tips or answer to my question please feel free to tell me , i will appreciate all kind of help.Thanks in advance.

2
  • Does the android library that provides the rectangle object work the exact same way as the Java library? It might be better to write your own collision detection algorithm. Commented Jun 6, 2012 at 17:39
  • yes it work prefect i just downloaded source code of a simple java game with rectangle collision and if works Commented Jun 6, 2012 at 17:49

1 Answer 1

1

Collision detection never has anything to do with the platform and language. The algorithm you use should work properly if it's a good one.

Here's an article to get you started and give you a good hint as to how to proceed about it.

There are certain libraries to help your cause.I recommend you to use the Box2d library.It is a physics engine with good support for collision. You can find an example on the front page of the site as well.

Sign up to request clarification or add additional context in comments.

5 Comments

thank you i read it but its a bit confusing for me cause i am new to programming :)
Look at the Box2d page. It is good to get you started. And the GameDev article wasn't so programming related for you to give that excuse. :-)
Box2d is for physics games,it detects collision 2 but it is not worth to load all that stuff i your game only to make a collision detection :)Thank you for your help , i appreciate that :D.I will try to do the article example and see if its work.
I just found why the intersects method didnt work.It was just because rectangles didnt move with characters -.- .Now i have an other problem , i cant change the x and y position of enemy class when it collides.I made methods to access it , but when i try to change it it says "The left-hand side of an assignment must be a variable".What can i do?(if you didnt understand my English , post a comment to rephrase.);
Ok i found the solution. Thanks you for your time :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.