浏览代码

fixed recursive unbind() to prevent binding conflicts

Nicolas Cannasse 11 年之前
父节点
当前提交
64a15ec49e
共有 3 个文件被更改,包括 16 次插入2 次删除
  1. 8 0
      h3d/anim/Animation.hx
  2. 2 2
      h3d/anim/SimpleBlend.hx
  3. 6 0
      h3d/anim/Transition.hx

+ 8 - 0
h3d/anim/Animation.hx

@@ -67,6 +67,14 @@ class Animation {
 		return f;
 		return f;
 	}
 	}
 
 
+	public function unbind( objectName : String ) {
+		for( o in objects )
+			if( o.objectName == objectName ) {
+				objects.remove(o);
+				return;
+			}
+	}
+
 	/**
 	/**
 		Register a callback function that will be called once when a frame is reached.
 		Register a callback function that will be called once when a frame is reached.
 	**/
 	**/

+ 2 - 2
h3d/anim/SimpleBlend.hx

@@ -14,10 +14,10 @@ class SimpleBlend extends Transition {
 	function setupInstance() {
 	function setupInstance() {
 		for( o in anim1.objects.copy() )
 		for( o in anim1.objects.copy() )
 			if( objectsMap.get(o.objectName) )
 			if( objectsMap.get(o.objectName) )
-				anim1.objects.remove(o);
+				anim1.unbind(o.objectName);
 		for( o in anim2.objects.copy() )
 		for( o in anim2.objects.copy() )
 			if( !objectsMap.get(o.objectName) )
 			if( !objectsMap.get(o.objectName) )
-				anim2.objects.remove(o);
+				anim2.unbind(o.objectName);
 		isInstance = true;
 		isInstance = true;
 	}
 	}
 
 

+ 6 - 0
h3d/anim/Transition.hx

@@ -17,6 +17,12 @@ class Transition extends Animation {
 		this.anim2 = anim2;
 		this.anim2 = anim2;
 	}
 	}
 
 
+	override function unbind( objectName : String ) {
+		super.unbind(objectName);
+		anim1.unbind(objectName);
+		anim2.unbind(objectName);
+	}
+
 	override function setFrame( f : Float ) {
 	override function setFrame( f : Float ) {
 		super.setFrame(f);
 		super.setFrame(f);
 		anim1.setFrame(frame % anim1.frameCount);
 		anim1.setFrame(frame % anim1.frameCount);