gamnit: add size info to font_showcase
authorAlexis Laferrière <alexis.laf@xymus.net>
Wed, 20 Sep 2017 16:38:56 +0000 (12:38 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Mon, 25 Sep 2017 15:11:12 +0000 (11:11 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/gamnit/examples/fonts_showcase/assets/corner.png [new file with mode: 0644]
lib/gamnit/examples/fonts_showcase/src/fonts_showcase.nit

diff --git a/lib/gamnit/examples/fonts_showcase/assets/corner.png b/lib/gamnit/examples/fonts_showcase/assets/corner.png
new file mode 100644 (file)
index 0000000..12f7986
Binary files /dev/null and b/lib/gamnit/examples/fonts_showcase/assets/corner.png differ
index d64c304..33a342c 100644 (file)
@@ -22,9 +22,12 @@ redef class App
        # Asset font used to display text
        var font = new BMFontAsset("Josefin_Sans/font.fnt")
 
-       # Anchor texture used to identify the anchor coordinate of each `TextSprites`
+       # Anchor texture identifying the anchor coordinates of each `TextSprites`
        var anchor = new Texture("anchor.png")
 
+       # Bottom right corner
+       var corner = new Texture("corner.png")
+
        redef fun on_create
        do
                super
@@ -170,6 +173,12 @@ redef class App
 
                # Add the anchor effects to all TextSprites
                for t in texts do ui_sprites.add new Sprite(anchor, t.anchor)
+
+               for t in texts do
+                       # Bottom right
+                       var br = t.anchor.offset(t.width*(1.0-t.align), -t.height*(1.0-t.valign), 1.0)
+                       ui_sprites.add new Sprite(corner, br)
+               end
        end
 
        redef fun accept_event(event)