Procházet zdrojové kódy

auto resize scene 2d on window resize (if not fixed size)

Nicolas Cannasse před 11 roky
rodič
revize
958b91cdad
2 změnil soubory, kde provedl 14 přidání a 1 odebrání
  1. 10 0
      h2d/Scene.hx
  2. 4 1
      hxd/App.hx

+ 10 - 0
h2d/Scene.hx

@@ -64,6 +64,16 @@ class Scene extends Layers implements h3d.IDrawable {
 		posChanged = true;
 	}
 
+	public function checkResize() {
+		if( fixedSize ) return;
+		var engine = h3d.Engine.getCurrent();
+		if( width != engine.width || height != engine.height ) {
+			width = engine.width;
+			height = engine.height;
+			posChanged = true;
+		}
+	}
+
 	override function onAlloc() {
 		stage.addEventTarget(onEvent);
 		super.onAlloc();

+ 4 - 1
hxd/App.hx

@@ -21,7 +21,10 @@ class App {
 	}
 
 	function setup() {
-		engine.onResized = onResize;
+		engine.onResized = function() {
+			s2d.checkResize();
+			onResize();
+		};
 		s3d = new h3d.scene.Scene();
 		s2d = new h2d.Scene();
 		s3d.addPass(s2d);