This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Hi all,

I have made several sprite sheets for my projects, but realised that I can't use several sprites at once since they overlap and are visible during each animation. How can I make it that only one animation plays, and the rest are hidden during the duration of the playing animation?

in Engine by (52 points)

1 Answer

0 votes

The ideal usage of a spritesheet is for one sprite to display a frame of a single spritesheet frame, if you need different spritesheets from other imagefiles load them during runtime or preload them into a library. There are many ways of doing a animation system, you should explore what suits you the best, the properties you are interested to make a spritesheet work are hframes, vframes, frame and region.

Hframes and Vframes specify how many frames horizontally and vertically will be used from your spritesheet, animating the frame property will actually play the animation contained in that spritesheet, and if you want only a portion of that imagefile you can use region to basically use only a piece of that imagefile.

I will exemplify that with a simple spritesheet:

enter image description here

This spritesheet can play a running animation in 4 directions, each animation has 1 Vframes and 4 Hframes. You can switch direction by modifying the region position and size accordingly.

Or you can use all frames, then it will become 4 hframes and 4 vframes, and you would limit the frame animation to 0-3 for a animation of walking down, 3-7 for a animation of walking left, and so on.

You can do this in GDScript too, which will become automatically once you develop a system for that, or you can do manually with the animation editor, creating a animation per direction and so on, which is more work but easier to set-up.

by (381 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.