I would like to make a persistent reference to my world that my actor's methods can use to access my world's methods & variables without having to re-define the world object each time it's used.
What I've tried so far compiles okay but gives a runtime error (null pointer). First I tried making a world variable and assigning it at once:
Next, I tried deferring the assignment until the actor's constructor is called:
Neither of these attempts were successful of course.
Can anyone help me avoid having to re-declare my world object in every method that needs to reference one of it's methods?
public class Wombat extends Actor { private WombatWorld MyWorld = (WombatWorld) getWorld();
public class Wombat extends Actor { private WombatWorld MyWorld ; public Wombat() { MyWorld = (WombatWorld) getWorld(); }