Make layers iterable.
authorSimon Cross <hodgestar@gmail.com>
Wed, 2 Mar 2016 21:53:03 +0000 (23:53 +0200)
committerSimon Cross <hodgestar@gmail.com>
Wed, 2 Mar 2016 21:53:03 +0000 (23:53 +0200)
koperkapel/scenes/base.py

index fd53f817b9cc6b3fade5a0b617f42a90e1f1e84f..16353d597e607f3a96ecdd1635c971362babdf29 100644 (file)
@@ -116,6 +116,9 @@ class Layer:
         self.name = name
         self.actors = []
 
+    def __iter__(self):
+        return iter(self.actors)
+
     def add(self, actor):
         self.actors.append(actor)
         return actor
@@ -154,7 +157,7 @@ class Actors:
 
     def draw(self, screen):
         for lvl, name in self._ordered_layers:
-            for actor in self._layers[name].actors:
+            for actor in self._layers[name]:
                 actor.draw()  # TODO: allow an option screen to be passed in