Splitting an image into pieces

Hello. I’m making a literal jigsaw game, for PC, my first project after numerous tutorials.

I am at the part where I need to split an image into the pieces for the jigsaw puzzle. The desired image is selected on a previous screen and will be loaded into (I think this is best) a TextureRect?

From there it will need to be split into X amount of pieces, selectable via an OptionButton.

How is it best to split up an image like this, it will need to end up as seperate nodes in order to be moved around and matched up. I have heard of Atlastexture, this seems to crop one part of an image. So if I did it this way would I end up with 100 cropped images?

I’m wondering if this is a bit out of my scope, i’ve not really found somebody doing something similar. When I see people using AtlasTexture they manually set the area in a popup window.

I’ve had a check of the documentation and that looks a bit promising, it looks like you can set it all via code, would this be the best way? I could do like a for loop making a new image and moving the region along the image each time for each seperate piece?

Thank you for the help

Doing something like this dynamically would pretty much be essential for anything more than a few pieces - way too inconvenient to do it manually.

Depending on the node you use, Region can be set on the node itself, so you don’t necessarily need an AtlasTexture to do this (Sprite2D has a Region property for example). That’s probably preferable, since you should then be able to use just the one copy of the image and configure each node as needed. More efficient, and you also won’t run into Godot’s annoying linked-duplicate Resource problems that way.