From e0ff7ad9c421d6eff905628a704a4e0693624b99 Mon Sep 17 00:00:00 2001 From: Firew0lf Date: Tue, 1 Sep 2015 18:23:12 +0200 Subject: [PATCH] Fixed the the getBox() function (only usable in the library) --- sdcard/3ds/ctruLua/libs/sprite.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sdcard/3ds/ctruLua/libs/sprite.lua b/sdcard/3ds/ctruLua/libs/sprite.lua index 8e5bc2c..53e9772 100644 --- a/sdcard/3ds/ctruLua/libs/sprite.lua +++ b/sdcard/3ds/ctruLua/libs/sprite.lua @@ -4,10 +4,12 @@ local mod = {} -- Module functions local function getBox(tx, ty, i, sx, sy) - x = (i%tx) - y = math.floor(i/tx) + x = ((i*sx)%tx) + y = math.floor((i*sx)/tx)*sy + + gfx.text(150, 150, tx.."/"..ty.." -> "..x.."/"..y) - return (x*sx), (y*sy) + return x, y end -- Sprite object methods @@ -39,10 +41,12 @@ end -- Set to 0 to hide the sprite local function setAnimation(self, anim) self.currentAnimation = anim - self.currentFrame = 1 if not self.animations[anim] then return false end + if not self.animations[anim].animation[self.currentFrame] then + self.currentFrame = 1 + end return true end