Scenes have a widget list (in draw order)
authorStefano Rivera <stefano@rivera.za.net>
Sun, 11 May 2014 16:03:18 +0000 (18:03 +0200)
committerStefano Rivera <stefano@rivera.za.net>
Sun, 11 May 2014 16:03:33 +0000 (18:03 +0200)
naja/scenes/menu.py
naja/scenes/scene.py

index 7b42ad7b730d90959f078e89c4ffe98ed13207d5..c1fd5f814513eddab54e345c9671b8dc312c9425 100644 (file)
@@ -9,10 +9,9 @@ from naja.widgets.text import TextWidget
 class MenuScene(Scene):
 
     def __init__(self):
-        self.tw = TextWidget((10, 10), 'Haai', colour=(255, 255, 255))
-
-    def render(self, surface):
-        self.tw.render(surface)
+        super(MenuScene, self).__init__()
+        self.widgets.append(TextWidget((10, 10), 'Haai',
+                            colour=(255, 255, 255)))
 
     def handle_event(self, ev):
         pass
index c82427d565790299f5cab195958a84df635a46d3..f0acf21bdf9f62a1f9fef85a1f3ce4771234c116 100644 (file)
@@ -10,7 +10,7 @@ class Scene(object):
     E.g. Splash screen, game board, credits, win, lose.
     """
     def __init__(self):
-        pass
+        self.widgets = []
 
     def enter(self):
         pass
@@ -19,7 +19,11 @@ class Scene(object):
         pass
 
     def render(self, surface):
-        pass
+        self.render_widgets(surface)
+
+    def render_widgets(self, surface):
+        for widget in self.widgets:
+            widget.render(surface)
 
     def handle_event(self, ev):
         pass