A practical pivot check when flipping a 2D character
By Liangqi Zhao, on behalf of the MotifDeck team. Prepared with AI assistance.
A character that jumps sideways when it turns is often flipping around the middle of its image instead of the point used to place it in the world. This check isolates the art transform from the game’s movement and collision logic.
Mark one point before flipping
Choose a stable pivot, such as the midpoint between the feet in the neutral pose. Draw a temporary cross at that point. Pause the animation on one frame and note the cross’s world position. Flip the image horizontally without moving the character. The cross should stay at the same world position.
A numeric example
Suppose the image is 64 pixels wide and its pivot is 20 pixels from the left edge. In continuous image coordinates, a horizontal reflection about that pivot maps x to 40 − x. The pivot at 20 stays at 20; the left edge at 0 moves to 40, and the right edge at 64 moves to −24. This assumes the pivot itself remains fixed in the world. Pixel-center indices use a different convention, so check your engine’s coordinate system.
Browser preview
In a simple CSS preview, set transform-origin: 20px 100%; and apply transform: scaleX(-1); to the image. This flips the image around the chosen horizontal origin; 100% places the vertical origin at its bottom edge. The 20px value must be in the image’s displayed CSS-pixel coordinates: if a 64px image is displayed at 128px wide, scale the horizontal pivot to 40px. See MDN’s transform-origin reference and scaleX reference.
Test the whole action
- Flip the paused neutral frame several times. If the cross moves, check the transform origin and the displayed image size.
- Step through the action in both directions. Different trimmed frame bounds may need individual offsets to keep the chosen point stable.
- Check attachments separately. A weapon or effect may need its own mirrored offset, and a shadow may be better kept independent.
- Test collision boxes and gameplay coordinates in the engine. Mirroring artwork alone does not automatically make every hitbox or attached object correct.
For an example of inspecting actual motion and selected transparent frames before export, the MotifDeck motion sample is public. MotifDeck is our own game-art workspace; this pivot check applies regardless of which art tool you use.
评论
发表评论