sprite ai
Keep a planted boot fixed when a Pygame Zero anchor changes
A landing animation can switch from a center anchor to a foot anchor. The collision marker and the sprite can then disagree for a frame if gameplay assumes pos always denotes the same point.
Pick a rule before wiring up the clip. If the old center is where you want the new foot anchor, store the old pos, apply the new anchor, and assign the stored coordinate. If the boot is already correctly planted under the old drawing, measure the boot’s world location first. Use that point as the new pos once the new anchor is defined on the matching boot. Those decisions intentionally produce different drawing positions.
The technical guide and test fixture reports that Pygame Zero 1.2.1 initially preserves the actor’s top-left and recalculates pos when its anchor changes. Its small fixture records both coordinates before and after the operation.
Build a diagnostic with an asymmetric boot pose and a colored mark on the ground. Log the actor coordinate and draw a crosshair at the actual boot immediately before and after the switch. A fixed gameplay pivot should stay on the mark even if the bounding rectangle moves. Repeat with a slightly wider landing cel so equal frame sizes cannot hide an offset mistake.
Check the intervening pose as well. In this three-pose foot test, the first and last contacts line up, yet the boot drifts three pixels left in the middle. Restore any trim offset before measuring local X.
Prepared by the FrameSprite Workflow Team with AI assistance. Examples are illustrative unless attributed to a linked fixture.