From f48de0e9bdaa96453e001cd834ed4de45cbeff2a Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 14 Jul 2019 18:48:25 +0200 Subject: [PATCH] improvement(camera): manually attach the view instead of using hump func --- gamecore/modules/world/camera/init.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/gamecore/modules/world/camera/init.lua b/gamecore/modules/world/camera/init.lua index 02019d3..6ac4ae6 100644 --- a/gamecore/modules/world/camera/init.lua +++ b/gamecore/modules/world/camera/init.lua @@ -185,7 +185,25 @@ function CameraSystem:attachView(id) if (id ~= nil) then local cam = self:getViewCam(id) - cam:attach() + if id ~= nil then + -- Du à la manière dont fonctionne STI, on est obligé de récupérer les info + -- de position de camera pour afficher la carte par rapport à ces infos + tx, ty = self:getInternalCamCoordinate(id) + tx, ty = core.screen:getScreenCoordinate(tx, ty) + scale = self:getViewScale(id) or 2 + local vx, vy = self:getOnScreenViewRelativePosition(id) + tx = math.floor(tx - math.abs(vx)) * -1 + ty = math.floor(ty - math.abs(vy)) * -1 + + local w, h = core.screen:getDimensions() + end + + print(tx, ty, scale) + + love.graphics.push() + love.graphics.origin() + love.graphics.translate(math.floor(tx), math.floor(ty)) + love.graphics.scale(scale, scale) end end @@ -193,7 +211,7 @@ function CameraSystem:detachView(id) if (id ~= nil) then local cam = self:getViewCam(id) - cam:detach() + love.graphics.pop() end end