Refactor
authorNeil <neil@dip.sun.ac.za>
Thu, 18 Apr 2013 14:27:36 +0000 (16:27 +0200)
committerNeil <neil@dip.sun.ac.za>
Thu, 18 Apr 2013 14:27:36 +0000 (16:27 +0200)
erdslangetjie/editor/editor.py

index 22fa0a4eb9018ce9e9ac50e87373284af57db9e8..ef08b813e01f7c2d30c4dccbda827ba2bbe21df1 100644 (file)
@@ -76,6 +76,8 @@ class EditorWindow(FloatLayout):
         self.draw_save_button()
 
     def _draw_tile(self, tile_pos, tile):
+        if tile_pos in self.nodes:
+            self.remove_widget(self.nodes[tile_pos])
         node = Widget(size=(TILE_SIZE, TILE_SIZE), pos=tile_pos)
         node.bind(on_touch_down=self.change_node)
         node.bind(on_touch_move=self.change_node)
@@ -149,8 +151,6 @@ class EditorWindow(FloatLayout):
                 self.level_obj.set_tile_type(tile_pos, action)
                 for map_pos, new_tile in self.level_obj.get_changed_tiles():
                     node_pos = (map_pos[0] * TILE_SIZE, map_pos[1] * TILE_SIZE)
-                    old_node = self.nodes[node_pos]
-                    self.remove_widget(old_node)
                     self._draw_tile(node_pos, new_tile)