From 257eec82907e763de319ad8abb0027b7e1bd1cff Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 1 May 2019 11:24:41 +0200 Subject: [PATCH] modules/assets: add a way to determine ox and oy in tileset metadata --- examples/gameplay/plateform/assets/monkey_lad.lua | 2 ++ gamecore/modules/assets/tileset.lua | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/examples/gameplay/plateform/assets/monkey_lad.lua b/examples/gameplay/plateform/assets/monkey_lad.lua index bbe147e..2ba5233 100644 --- a/examples/gameplay/plateform/assets/monkey_lad.lua +++ b/examples/gameplay/plateform/assets/monkey_lad.lua @@ -2,6 +2,8 @@ return { metadata = { height = 24, width = 32, + ox = 16, + oy = 12, defaultAnim = "idle" }, animations = { diff --git a/gamecore/modules/assets/tileset.lua b/gamecore/modules/assets/tileset.lua index a2f5dff..9c83c4f 100644 --- a/gamecore/modules/assets/tileset.lua +++ b/gamecore/modules/assets/tileset.lua @@ -91,15 +91,21 @@ end function Tileset:drawTile_Grid(i, j, x, y, r, sx, sy, ox, oy, kx, ky) local tileID = self:getTileID_Grid(i, j) + local ox = ox or self.metadata.ox + local oy = oy or self.metadata.oy self.texture:drawQuad(self.quads[tileID], x, y, r, sx, sy, ox, oy, kx, ky) end function Tileset:drawTile(id, x, y, r, sx, sy, ox, oy, kx, ky) + local ox = ox or self.metadata.ox + local oy = oy or self.metadata.oy self.texture:drawQuad(self.quads[id], x, y, r, sx, sy, ox, oy, kx, ky) end function Tileset:drawTileMask_Grid(i, j, x, y, r, sx, sy, ox, oy, kx, ky) local tileID = self:getTileID_Grid(i, j) + local ox = ox or self.metadata.ox + local oy = oy or self.metadata.oy self.texture:drawMaskQuad(self.quads[tileID], x, y, r, sx, sy, ox, oy, kx, ky) end