fixed tile flickering by fixing camera to pixel grid
This commit is contained in:
@@ -34,14 +34,16 @@ end
|
||||
--- @param y (number)
|
||||
function Camera:moveTo(x, y)
|
||||
-- TODO: Smoothing function
|
||||
self.target = { x = x, y = y }
|
||||
self.camera:setPosition(x, y)
|
||||
local snapx, snapy = math.floor(x), math.floor(y)
|
||||
self.target = { x = snapx, y = snapy }
|
||||
self.camera:setPosition(snapx, snapy)
|
||||
end
|
||||
|
||||
function Camera:shake(intensity)
|
||||
local t = 1 - intensity
|
||||
local vx, vy = vector.randomDirection(math.exp(t * 5))
|
||||
self.camera:setPosition(self.target.x + vx, self.target.y + vy)
|
||||
local snapvx, snapvy = math.floor(vx), math.floor(vy)
|
||||
self.camera:setPosition(self.target.x + snapvx, self.target.y + snapvy)
|
||||
end
|
||||
|
||||
return Camera
|
||||
|
||||
Reference in New Issue
Block a user