Hi,
I'm new to programming and I'm creating a little game with Greenfoot. In that game, the "Player" class is supposed to check if the player is touched by an enemie. I created an "Enemie" class with several subclasses to code some aspects differently for some enemies. However, when the player is touched by any enemie, the game should restart. I got everything working as it should be, but I just copied the use of getOneIntersectingObject from another scenario and changed everything I needed to change:
This code is working fine, but I want to understand it aswell. The method getOneIntersectingObject checks if an enemie and the player are intersecting, but what does the "null" stand for and what type of information is that?
Thank you for answering!
1 2 3 4 | if (getOneIntersectingObject(Enemie. class ) != null ) { my code } |