Skip to content

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 ​

ParameterTypeDefault value
viewPositionedundefined
bodyBodyundefined
alphanumberundefined
offsetXnumber0
offsetYnumber0
roundbooleanfalse

Returns ​

void

Released under the MIT License.