gamnit: fix animations with a single frame
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 14 Jul 2017 16:21:17 +0000 (12:21 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 28 Jul 2017 19:06:27 +0000 (15:06 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/gamnit/flat/flat_core.nit

index 6cd0411..800b3de 100644 (file)
@@ -1211,8 +1211,12 @@ private class SpriteContext
                                data[o+36] = tc[v*2+1]
 
                                # a_tex_diff
-                               var dx = animation.frames[1].texture_coords[0] - animation.frames[0].texture_coords[0]
-                               var dy = animation.frames[1].texture_coords[1] - animation.frames[0].texture_coords[1]
+                               var dx = 0.0
+                               var dy = 0.0
+                               if animation.frames.length > 1 then
+                                       dx = animation.frames[1].texture_coords[0] - animation.frames[0].texture_coords[0]
+                                       dy = animation.frames[1].texture_coords[1] - animation.frames[0].texture_coords[1]
+                               end
                                data[o+37] = dx
                                data[o+38] = dy