Godot 图集裁切后角色偏移?核对 AtlasTexture margin
对照 AtlasTexture 的源区域、逻辑尺寸和绘制偏移,验证留白如何影响精灵对齐。


图集裁出来的药水图案是对的,切换帧时却横移。先检查每帧的逻辑尺寸和绘制位置。以下步骤针对 Godot 4.5 的 AtlasTexture,使用整数坐标,两轴裁切尺寸都大于零。
固定原图集,只改逻辑留白
从同一张图集裁出 24×32 像素,在两个 AtlasTexture 中填写相同的 region。A 的 margin 为零。B 把 margin 的位置设成 (4, 0),尺寸设成 (8, 0)。两张 Texture 使用相同的上左绘制点,记录 get_size(),把两张图与同一条参考线对齐查看。
分别检查尺寸和偏移
A 的逻辑尺寸为 24×32,B 为 32×32。以同一左上角绘制时,B 的可见内容向右移 4 像素,仍引用原裁切范围。若使用默认居中的 Sprite2D,还要看逻辑尺寸对居中位置的影响。margin 的位置和尺寸分别描述偏移和增量,不能只填其中一个就指望恢复裁切前的画布。可以先用图集打包工具整理对照图集,再在 Godot 检查资源属性。
推荐使用本站工具

Sprite Sheet Splitter Guide: Extract Animation Frames for 2D Games
Learn how a sprite sheet splitter extracts clean animation frames from character sheets, VFX sheets, tiles, UI sprites, and AI-generated game assets.

Best Sprite Sheet Packer Settings for Indie Game Assets
A practical SEO-friendly guide to sprite sheet packer settings, including atlas size, padding, trimming, extrude, rotation, metadata, and recommended export settings for 2D game assets.

Smart Sprite Sheet Packer: A Practical Guide for 2D Game Developers
Learn how a smart sprite sheet packer helps indie game developers combine PNG assets into clean texture atlases with metadata for Unity, Cocos, Godot, and custom 2D game engines.
