2

I'm using the Greenfoot program to create a game, but cannot instantiate anything in a constructor. For some reason, nothing is made when I write getWorld().addObject() in the constructor.

I can create objects in the act() method, though.

hatze
  • 521
  • 4
  • 12
Big Chungus
  • 185
  • 1
  • 3
  • 13

1 Answers1

2

Since Greenfoot only allows you to add objects from a world object, the other actors you are calling don't exist yet. This means there are no constructors to call getworld() on.

Curtis Chong
  • 783
  • 2
  • 13
  • 26