I'm having an issue with a students' project.
The student is adding an object to their game. Let's call it a Shooter.
However, the students are monitoring object counts using getObjects(Shooter.class).size()
For some reason, when a single object is created and added to the World, the getObjects class has a size of 2. I used the following code to try to troubleshoot:
The x and y coordinates are identical. The second output statement outputs true. There is only one object visibly in the world, and dragging it away does not reveal a second object.
I'm very confused. What could result in the getObjects method getting the same object twice like this?
(This is one of my students, working on a school computer, on Greenfoot 2.3.0)
ArrayList<Shooter> shooters = (ArrayList<Shooter>)getObjects(Shooter.class); for (Shooter s : shooters){ System.out.println(s.getX() + ", " + s.getY()); } System.out.println(shooters.get(0) == shooters.get(1));