1681-engine / index / syncToBody
Function: syncToBody() ​
ts
function syncToBody(
view,
body,
alpha,
offsetX?,
offsetY?,
round?
): void;Defined in: src/physics/syncToBody.ts:17
Places view where body is drawn this frame: between its last two step positions by the loop's alpha (SystemContext.alpha in a frame system), so motion is smooth at any refresh rate even though physics steps at a fixed rate. Pass round for pixel art, so the view lands on whole pixels. A body that rotates (or was placed at an angle) turns the view too, by the shorter way between its last two angles; the offset is turned with it.
Parameters ​
| Parameter | Type | Default value |
|---|---|---|
view | Positioned | undefined |
body | Body | undefined |
alpha | number | undefined |
offsetX | number | 0 |
offsetY | number | 0 |
round | boolean | false |
Returns ​
void