Can anyone point me to a forum topic or sample code that discusses the best approach on how to pass around "global objects".
I have a Non Player Controller State that controls a NPC. It needs access to the terrain, 2D text etc that is setup in another game state.
What is the best way to pass these objects around? I can pass Terrain and Text in the constructor for the GameState but I worry about Threading issues.
Any Help?
Well, in Java there are no globals, but you can simulate them by having a class filled with static fields.
package my.package;
public class Globals
{
public static ContollerState npc = null;
// ...
}
To access these globals:
my.package.Globals.npc = blah();