From 5968f82d52d96b98454a48191638f08952244e03 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 2 Aug 2019 13:52:50 +0200 Subject: [PATCH] feat(camera): add a way to lock the camera position --- .../core/modules/world/camera/init.lua | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sonic-radiance.love/core/modules/world/camera/init.lua b/sonic-radiance.love/core/modules/world/camera/init.lua index 49487ff..9a136c4 100644 --- a/sonic-radiance.love/core/modules/world/camera/init.lua +++ b/sonic-radiance.love/core/modules/world/camera/init.lua @@ -42,6 +42,9 @@ function CameraSystem:new(world) self.verticalSplit = SPLITSCREEN_ISVERTICAL self.targets = {} + self.xLocked = nil + self.yLocked = nil + self:initViews() end @@ -103,6 +106,23 @@ function CameraSystem:getViewPositions(id) end +function CameraSystem:lockX(x) + self.xLocked = x +end + +function CameraSystem:unlockX() + self.xLocked = nil +end + +function CameraSystem:lockY(y) + self.yLocked = y +end + +function CameraSystem:unlockY() + self.yLocked = nil +end + + -- WRAPPER and UTILS -- Access data from the views @@ -279,6 +299,14 @@ function CameraSystem:limitView(id) self.views.list[id].x = utils.math.between(posx, minx, maxx) self.views.list[id].y = utils.math.between(posy, miny, maxy) + + if (self.xLocked ~= nil) then + self.views.list[id].x = self.xLocked + end + + if (self.yLocked ~= nil) then + self.views.list[id].y = self.yLocked + end end -- UPDATE and MOVE functions