I want to spawn an object at the cursor position. However the MouseInfo seems to always be null. (If Crab spawns -> mouse == null)
I've also tried this with a while loop instead of for because i thought maybe its just null right after executing the method. The results were the same.
public void SpawnMode() { MouseInfo mouse = Greenfoot.getMouseInfo(); if(mouse != null) { int x = mouse.getX(); int y = mouse.getY(); addObject(new Crab(),x,y); } addObject(new Crab(),500,500); }