Skip to content
This repository was archived by the owner on Mar 8, 2023. It is now read-only.

Commit 243e67b

Browse files
authored
Merge pull request a327ex#8 from npinochet/master
Shake now returns to original coordinates
2 parents c255fc1 + b314e8b commit 243e67b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Camera.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ local function new(x, y, w, h, scale, rotation)
9292
deadzone = nil, bound = nil,
9393
draw_deadzone = false,
9494
flash_duration = 1, flash_timer = 0, flash_color = {0, 0, 0, 1},
95+
last_horizontal_shake_amount = 0, last_vertical_shake_amount = 0,
9596
fade_duration = 1, fade_timer = 0, fade_color = {0, 0, 0, 0},
9697
}, Camera)
9798
end
@@ -178,7 +179,9 @@ function Camera:update(dt)
178179
vertical_shake_amount = vertical_shake_amount + getShakeAmplitude(self.vertical_shakes[i])
179180
if not self.vertical_shakes[i].shaking then table.remove(self.vertical_shakes, i) end
180181
end
182+
self.x, self.y = self.x - self.last_horizontal_shake_amount, self.y - self.last_vertical_shake_amount
181183
self:move(horizontal_shake_amount, vertical_shake_amount)
184+
self.last_horizontal_shake_amount, self.last_vertical_shake_amount = horizontal_shake_amount, vertical_shake_amount
182185

183186
-- Follow --
184187
if not self.target_x and not self.target_y then return end

0 commit comments

Comments
 (0)