Das ist wohl der erste “self containing singleton” (so habe ich ihn getauft) in D:
8: /// Singleton instance. 9: private static SceneManager singleton; 10: 11: /// No public need for this. 12: private static this() { 13: singleton = new SceneManager(); 14: } 15: 16: /// Get signleton instance. 17: public static SceneManager opCall() { 18: if(singleton == null) 19: singleton = new SceneManager(); 20: return singleton; 21: }
z.B.:
SceneManager().registerScene(new DebugScene());
SceneManager().registerScene(new StarfieldScene());
Bookmarks