Pārlūkot izejas kodu

added onParentChanged()

ncannasse 12 gadi atpakaļ
vecāks
revīzija
f02af58b46
2 mainītis faili ar 13 papildinājumiem un 0 dzēšanām
  1. 7 0
      h2d/Interactive.hx
  2. 6 0
      h2d/Sprite.hx

+ 7 - 0
h2d/Interactive.hx

@@ -28,6 +28,13 @@ class Interactive extends Sprite {
 		super.onAlloc();
 	}
 	
+	override function onParentChanged() {
+		if( scene != null ) {
+			scene.removeEventTarget(this);
+			scene.addEventTarget(this);
+		}
+	}
+	
 	override function onDelete() {
 		if( scene != null ) {
 			scene.removeEventTarget(this);

+ 6 - 0
h2d/Sprite.hx

@@ -73,10 +73,16 @@ class Sprite {
 		if( allocated ) {
 			if( !s.allocated )
 				s.onAlloc();
+			else
+				s.onParentChanged();
 		} else if( s.allocated )
 			s.onDelete();
 	}
 	
+	// called when we're allocated already but moved in hierarchy
+	function onParentChanged() {
+	}
+	
 	// kept for internal init
 	function onAlloc() {
 		allocated = true;