+ 2
Detecting Sprite Collision (Java)
I have a sprite class...now I want sprites I create with this class to detect collision with each other or among themselves.
2 odpowiedzi
+ 4
To check for collision, add a Rectangle variable in the sprite class and create a new Rectangle for each sprite with the position and size of the object. You can draw a rectangle with graphics using the Rectangle's values to have visual appearance of its position.
Create some other class and call it 'Collision' and use the method I sent you..
p.s. Don't forget to move the Rectangles to the sprite's position every time they move..
https://code.sololearn.com/c9Vmu1vznWF4/?ref=app
0
@Robby S, thanks a lot.