mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +00:00
Fixed the the getBox() function (only usable in the library)
This commit is contained in:
parent
e8471ce6e6
commit
e0ff7ad9c4
1 changed files with 8 additions and 4 deletions
|
|
@ -4,10 +4,12 @@ local mod = {}
|
||||||
|
|
||||||
-- Module functions
|
-- Module functions
|
||||||
local function getBox(tx, ty, i, sx, sy)
|
local function getBox(tx, ty, i, sx, sy)
|
||||||
x = (i%tx)
|
x = ((i*sx)%tx)
|
||||||
y = math.floor(i/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
|
end
|
||||||
|
|
||||||
-- Sprite object methods
|
-- Sprite object methods
|
||||||
|
|
@ -39,10 +41,12 @@ end
|
||||||
-- Set to 0 to hide the sprite
|
-- Set to 0 to hide the sprite
|
||||||
local function setAnimation(self, anim)
|
local function setAnimation(self, anim)
|
||||||
self.currentAnimation = anim
|
self.currentAnimation = anim
|
||||||
self.currentFrame = 1
|
|
||||||
if not self.animations[anim] then
|
if not self.animations[anim] then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
if not self.animations[anim].animation[self.currentFrame] then
|
||||||
|
self.currentFrame = 1
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue