Adds a member; adding the same one twice is a no-op, so a spawn loop can call this every frame without growing the group.
empties the group, for a scene change
Advances every member on screen by dt, skipping the rest. margin grows the
tested box the way isOnScreen's does, for members larger than a point.
A crowd that only animates its on-screen members.
TileMap.cull(camera)keeps tile rendering cost to what is on screen; this is the same idea for per-frame animation cost. A scene with hundreds of animated inhabitants callsgroup.update(camera, dt)once per frame instead of updating each sprite itself, and members outsidecamera.view(plusmargin) simply keep whatever frame they had until they come back into view. Skipped members are never touched: nopausedflag is set, no state is rewritten, so a sprite that leaves the group animates exactly as before.Members are positioned in the camera's own world units, the way
GridMoverandTileMap.tileCenteralready place things: direct children ofcamera.world, or anything else whosex/yalready read as world coordinates. Members nested deeper (a sword in a hero's hand) report their local position, so they belong to no group, or to one updated unconditionally.Example