Browse Source

filter interactive events outside scene bounds

Nicolas Cannasse 4 months ago
parent
commit
d5364dc219
1 changed files with 3 additions and 1 deletions
  1. 3 1
      h2d/Scene.hx

+ 3 - 1
h2d/Scene.hx

@@ -525,6 +525,8 @@ class Scene extends Layers implements h3d.IDrawable implements hxd.SceneEvents.I
 		screenToViewport(event);
 		var ex = event.relX;
 		var ey = event.relY;
+		if( ex < 0 || ey < 0 || ex >= width || ey >= height )
+			return null;
 		var index = last == null ? 0 : interactive.indexOf(cast last) + 1;
 		var pt = shapePoint;
 		for( idx in index...interactive.length ) {
@@ -905,7 +907,7 @@ class Scene extends Layers implements h3d.IDrawable implements hxd.SceneEvents.I
 			var tex = new h3d.mat.Texture(width, height, [Target]);
 			target = new Tile(tex,0, 0, width, height);
 		}
-		
+
 		var tex = target.getTexture();
 		engine.begin();
 		engine.pushTarget(tex);