godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.07k stars 68 forks source link

Allow AnimatedSprite2D to use texture atlas regions #8357

Open TheColorRed opened 7 months ago

TheColorRed commented 7 months ago

Describe the project you are working on

Shooter

Describe the problem or limitation you are having in your project

When creating an animated sprite, you can use a sprite sheet, but the sheet needs to be in a grid. I would like it if you could use regions the same way that a Spirte2D uses regions for sheets that are not already in a grid such as this one where there are parts in a grid and parts that are not. (in this example, I want the items from the bottom right):

image

Source: https://kenney.nl/assets/tanks

Having the editor auto select the regions and then you select which region you want would be helpful.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

This would help so that the images don't have to be aligned to a perfect grid.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Same as it does now, only with the addition of non-grid based images.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Not that I am aware of.

Is there a reason why this should be core and not an add-on in the asset library?

Not sure.

Calinou commented 7 months ago

This already exists in the form of texture atlas functionality (see AtlasTexture). See https://godotengine.org/article/atlas-support-returns-godot-3-2/ and https://github.com/godotengine/godot-proposals/issues/7719#issuecomment-1724289929.

TheColorRed commented 7 months ago

Am I missing something... Using an atlas doesn't seem to help. Based on that link it shows how to create one atlas from multiple pngs. I have one png that is basically already an atlas, just not in a grid which the AnimatedSprite2D is looking for. How can I extract the individual images?