Sfoglia il codice sorgente

added hxd.App.setCurrent

Nicolas Cannasse 6 anni fa
parent
commit
fb49dd92cb
1 ha cambiato i file con 15 aggiunte e 0 eliminazioni
  1. 15 0
      hxd/App.hx

+ 15 - 0
hxd/App.hx

@@ -85,6 +85,21 @@ class App implements h3d.IDrawable {
 			this.s3d = new3D;
 	}
 
+	/**
+	 * When using multiple hxd.App, this will set the current App (the one on which update etc. will be called)
+	**/
+	public function setCurrent() {
+		engine = h3d.Engine.getCurrent(); // if was changed
+		isDisposed = false;
+		engine.onReady = staticHandler; // in case we have another pending app
+		engine.onResized = function() {
+			if( s2d == null ) return; // if disposed
+			s2d.checkResize();
+			onResize();
+		};
+		hxd.System.setLoop(mainLoop);
+	}
+
 	function setScene2D( s2d : h2d.Scene, disposePrevious = true ) {
 		sevents.removeScene(this.s2d);
 		sevents.addScene(s2d,0);