diff pyink/tween.py @ 1172:178b126edd2c

Implement the correct normal tween. We will duplicate the node in the start scene. Insted of deleting all nodes which is not in the stop scene, we should delete the object which is not in the start scene instead. If we delete objecvt the the stop scene, the object should appear until we reach the stop scene.
author wycc
date Thu, 30 Dec 2010 11:50:02 +0800
parents e64b02951627
children 25e1579ed3d1
line wrap: on
line diff
--- a/pyink/tween.py	Thu Dec 30 11:32:33 2010 +0800
+++ b/pyink/tween.py	Thu Dec 30 11:50:02 2010 +0800
@@ -61,14 +61,26 @@
 		pass
 	    node = node.next()
 	    pass
+	# Collect all nodes in start scene
+	start_nodes = {}
+	node = start_scene_group.firstChild()
+	while node:
+	    try:
+		node_label = node.getAttribute("id")
+		start_nodes[node_label] = node
+	    except:
+		pass
+	    node = node.next()
+	    pass
 
-	# Remove duplicate nodes that is not in the set of stop nodes
-	#for node_ref in dup_nodes:
-	#    if node_ref not in stop_nodes:
-	#	node = dup_nodes[node_ref]
-	#	duplicate_group.removeChild(node)
-	#	pass
-	#   pass
+
+	# Remove duplicate nodes that is not in the set of start nodes
+	for node_ref in dup_nodes:
+	    if node_ref not in start_nodes:
+		node = dup_nodes[node_ref]
+		duplicate_group.removeChild(node)
+		pass
+	    pass
 
 	#
 	# Node ID of a node of start scene must be mapped to
@@ -176,6 +188,7 @@
 	    self.updateTweenObjectScale(obj,s,d,p,newobj)
 	    pass
 	elif typ == self.TWEEN_TYPE_NORMAL:
+	    print "newobj=",newobj
 	    if newobj == None:
 	        newobj = s.duplicate(self.document)
 	        newobj.setAttribute("ref", s.getAttribute("id"))
@@ -197,7 +210,6 @@
 	    top.setAttribute("ref",s.getAttribute("id"))
 	    top.appendChild(newobj)
 	    obj.appendChild(top)
-	    print "aaa"
 	else:
 	    top = newobj
 	    newobj = top.firstChild()