mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-28 00:39:30 +00:00
Changed spaces to tabs, Fixed a potential bug, Removed debug stuff
This commit is contained in:
parent
a4a6e09d74
commit
e8471ce6e6
1 changed files with 18 additions and 19 deletions
|
|
@ -4,7 +4,6 @@ local mod = {}
|
||||||
|
|
||||||
-- Module functions
|
-- Module functions
|
||||||
local function getBox(tx, ty, i, sx, sy)
|
local function getBox(tx, ty, i, sx, sy)
|
||||||
--i = i - 1
|
|
||||||
x = (i%tx)
|
x = (i%tx)
|
||||||
y = math.floor(i/tx)
|
y = math.floor(i/tx)
|
||||||
|
|
||||||
|
|
@ -14,12 +13,6 @@ end
|
||||||
-- Sprite object methods
|
-- Sprite object methods
|
||||||
local function draw(self, x, y, rad)
|
local function draw(self, x, y, rad)
|
||||||
if not self.animations[self.currentAnimation] then return 0 end
|
if not self.animations[self.currentAnimation] then return 0 end
|
||||||
local frame = self.animations[self.currentAnimation].animation[self.currentFrame]
|
|
||||||
local tsx, tsy = self.texture:getSize()
|
|
||||||
|
|
||||||
local sx, sy = getBox(tsx, tsy, frame, self.frameSizeX, self.frameSizeY)
|
|
||||||
gfx.text(200, 200, sx.."/"..sy)
|
|
||||||
self.texture:drawPart(x, y, sx, sy, self.frameSizeX, self.frameSizeY, rad)
|
|
||||||
|
|
||||||
if (ctr.time()-self.frameTimer) >= self.animations[self.currentAnimation].delay then
|
if (ctr.time()-self.frameTimer) >= self.animations[self.currentAnimation].delay then
|
||||||
self.currentFrame = (self.currentFrame+1)
|
self.currentFrame = (self.currentFrame+1)
|
||||||
|
|
@ -29,6 +22,12 @@ local function draw(self, x, y, rad)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local frame = self.animations[self.currentAnimation].animation[self.currentFrame]
|
||||||
|
local tsx, tsy = self.texture:getSize()
|
||||||
|
|
||||||
|
local sx, sy = getBox(tsx, tsy, frame, self.frameSizeX, self.frameSizeY)
|
||||||
|
self.texture:drawPart(x, y, sx, sy, self.frameSizeX, self.frameSizeY, rad)
|
||||||
|
|
||||||
return frame
|
return frame
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue