This following code works for me in a test project:
tool
extends Sprite
var not_snapped_pos;
func _ready():
not_snapped_pos = global_position;
set_notify_transform(true);
func _process(delta):
not_snapped_pos += Vector2(32, 0) * delta;
func _notification(what):
# Snap the global position to a 32x32 grid
if (what == NOTIFICATION_TRANSFORM_CHANGED):
global_position.x = floor(not_snapped_pos.x / 32) * 32;
global_position.y = floor(not_snapped_pos.y / 32) * 32;
However to get it working in the editor I had to close and reopen the scene a couple times so the code in _ready
was called.
I don't think you need to create a child node to receive the notifications, though it might be something to look at if the notifications are still not sent to the _notification
function in the sprite.