Skip to content

Commit 307b9cd

Browse files
committed
Changes related to camera follow
* Added camera.follow_offset() * Added check that the follow target exists Additional changes: * Moved message constants to camera. * Removed support for old message signature of camera.follow() * Added basic example of camera bounds
1 parent b763d3f commit 307b9cd

File tree

15 files changed

+656
-411
lines changed

15 files changed

+656
-411
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ The API can be used in two ways:
180180
1. Calling functions on the `camera.lua` module
181181
2. Sending messages to the `camera.script`
182182

183+
183184
### camera.shake(camera_id, [intensity], [duration], [direction], [cb])
184185
Shake the camera.
185186

@@ -197,7 +198,6 @@ Stop shaking the camera.
197198
**PARAMETERS**
198199
* `camera_id` (hash|url)
199200

200-
201201
### camera.recoil(camera_id, offset, [duration])
202202
Apply a recoil effect to the camera. The recoil will decay using linear interpolation.
203203

@@ -241,12 +241,22 @@ Acceptable values for the `options` table:
241241
* `vertical` (boolean) - True if following the target along the vertical axis.
242242
* `immediate` (boolean) - True if the camera should be immediately positioned on the target even when lerping.
243243

244+
245+
### camera.follow_offset(camera_id, offset)
246+
Change the camera follow offset.
247+
248+
**PARAMETERS**
249+
* `camera_id` (hash|url)
250+
* `offset` (vector3) - Camera offset from target position.
251+
252+
244253
### camera.unfollow(camera_id)
245254
Stop following a game object.
246255

247256
**PARAMETERS**
248257
* `camera_id` (hash|url)
249258

259+
250260
### camera.deadzone(camera_id, left, top, right, bottom)
251261
If following a game object this will add a deadzone around the camera position where the camera position will not update. If the target moves to the edge of the deadzone the camera will start to follow until the target returns within the bounds of the deadzone.
252262

@@ -257,6 +267,7 @@ If following a game object this will add a deadzone around the camera position w
257267
* `right` (number) - Number of pixels to the right of the camera
258268
* `bottom` (number) - Number of pixels below the camera
259269

270+
260271
### camera.bounds(camera_id, left, top, right, bottom)
261272
Limits the camera position to within the specified rectangle.
262273

@@ -404,10 +415,15 @@ Message equivalent to `camera.recoil()`. Accepted message keys: `offset` and `du
404415
Message sent back to the sender of a `shake` message when the shake has completed.
405416

406417
### follow
407-
Message equivalent to `camera.follow()`. Accepted message keys: `target`, `lerp`, `horizontal`, `vertical`, `immediate`.
418+
Message equivalent to `camera.follow()`. Accepted message keys: `target`, `lerp`, `horizontal`, `vertical`, `immediate`, `offset`.
408419

409420
msg.post("camera", "follow", { target = hash("player"), lerp = 0.7, horizontal = true, vertical = false, immediate = true })
410421

422+
### follow_offset
423+
Message equivalent to `camera.follow_offset()`. Accepted message keys: `offset`.
424+
425+
msg.post("camera", "follow_offset", { offset = vmath.vector3(150, 250, 0) })
426+
411427
### unfollow
412428
Message equivalent to `camera.unfollow()`.
413429

example/allfeature/example.collection

Lines changed: 0 additions & 284 deletions
This file was deleted.

0 commit comments

Comments
 (0)