Closed edbentley closed 2 years ago
This PR introduces Mutable Sprites, an alternative API to reduce the amount of GC to be collected.
Breaking changes:
getInputs
cleanup
updateState
loop
parentX
parentY
spriteToGameCoords
import { makeMutableSprite, t2 } from "@replay/core"; import { Player } from "./player"; export const Level = makeMutableSprite({ init() { return { playerX: 0 }; }, loop({ state }) { state.playerX++; }, render({ state }) { return [ t2.circle( { radius: 20, color: "purple", }, (thisProps) => { thisProps.x = state.playerX; } ), Player.Single( { rotation: 10, color: "red", }, (thisProps) => { thisProps.x = state.playerX; } ), ]; }, });
This PR introduces Mutable Sprites, an alternative API to reduce the amount of GC to be collected.
Breaking changes:
getInputs
removed fromcleanup
methodupdateState
removedloop
mutates state, not return itparentX
,parentY
replaced withspriteToGameCoords