lib/gamnit flat: intro `show_splash_screen`
authorAlexis Laferrière <alexis.laf@xymus.net>
Sun, 24 Jan 2016 16:02:34 +0000 (11:02 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 25 Jan 2016 19:10:43 +0000 (14:10 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/gamnit/flat.nit

index d415ded..b598f01 100644 (file)
@@ -212,6 +212,27 @@ redef class App
        # Main method to refine in clients to update game logic and `sprites`
        fun update(dt: Float) do end
 
+       # Display `texture` as a splash screen
+       #
+       # Load `texture` if needed and resets `ui_camera` to 1080 units on the Y axis.
+       fun show_splash_screen(texture: Texture)
+       do
+               texture.load
+
+               ui_camera.reset_height 1080.0
+
+               var splash = new Sprite(texture, ui_camera.center)
+               ui_sprites.add splash
+
+               var display = display
+               assert display != null
+               glClear gl_COLOR_BUFFER_BIT
+               frame_core_flat display
+               display.flip
+
+               ui_sprites.remove splash
+       end
+
        redef fun on_stop
        do
                # Clean up