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.KChaloux– KChaloux2012-06-06 17:39:51 +00:00Commented 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 worksJohn ThePartizan– John ThePartizan2012-06-06 17:49:46 +00:00Commented Jun 6, 2012 at 17:49
Add a comment
|
1 Answer
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.
5 Comments
John ThePartizan
thank you i read it but its a bit confusing for me cause i am new to programming :)
Kazekage Gaara
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. :-)
John ThePartizan
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.
John ThePartizan
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.);
John ThePartizan
Ok i found the solution. Thanks you for your time :)