Documentation / @debuffjp/core / SmoothMotion
Class: SmoothMotion
Defined in: core/src/smooth.ts:31
Smooth drawing between fixed steps. The simulation runs at 60 Hz, so on a 120 Hz display (or any frame between two steps) an object drawn at its position jumps every other frame. Draw it at x(o), y(o) instead: its position blended from where it was before the latest step by the render alpha.
Positions are saved before every step for the objects objects() returns, so new objects need no registering and removed ones no clean-up. An object is drawn where it is, unblended, when the latest step didn't save it: just created, after a frozen step (game.freeze), or after snap(o) (call it when you teleport something, so it doesn't streak across the screen for one step).
Rendering only: it never changes positions, so replays and tests are unaffected. Only x and y blend.
Constructors
Constructor
new SmoothMotion(
game,objects):SmoothMotion
Defined in: core/src/smooth.ts:35
Parameters
game
objects
Returns
SmoothMotion
Methods
at()
at(
o,alpha?):Positioned
Defined in: core/src/smooth.ts:55
Both, as a new object. Prefer x() and y() for many objects a frame.
Parameters
o
alpha?
number = ...
Returns
dispose()
dispose():
void
Defined in: core/src/smooth.ts:65
Stop saving positions.
Returns
void
snap()
snap(
o):void
Defined in: core/src/smooth.ts:60
Draw o where it is until the next step: after a teleport, a respawn or a warp.
Parameters
o
Returns
void
x()
x(
o,alpha?):number
Defined in: core/src/smooth.ts:43
o.x where it should be drawn this frame. alpha defaults to this render's (game.camera.renderAlpha).
Parameters
o
alpha?
number = ...
Returns
number
y()
y(
o,alpha?):number
Defined in: core/src/smooth.ts:49
o.y where it should be drawn this frame.
Parameters
o
alpha?
number = ...
Returns
number