Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to specify per-animation offsets to AnimatedSprite #665

Open
iway1 opened this issue Apr 3, 2020 · 2 comments
Open

Add a way to specify per-animation offsets to AnimatedSprite #665

iway1 opened this issue Apr 3, 2020 · 2 comments

Comments

@iway1
Copy link

iway1 commented Apr 3, 2020

Describe the project you are working on:
Top down RTS game.

Describe the problem or limitation you are having in your project:
Characters use an AnimatedSprite node to change between their respective animations. The animations have different center points by their pixel value.

Changing the offset always affects every animation, so it is impossible for both animations to be centered correctly when contained within the same AnimatedSprite. This results in at least one animation being offcenter.

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

Allow offsets to be specified per animation, giving a different offset to each animation in question.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

Allow multiple offsets to be specified in the editor.

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

It can be worked around by using the frame_changed() signal. It requires hardcoding the offsets per animation which isn't a desirable solution. It will cause additional code to be ran every single frame to check whether the animation has changed. If there were some "animation_changed()" signal that would be much more efficient and match the problem better.

Is there a reason why this should be core and not an add-on in the asset library?:
Not a big enough feature to warrant an add on. It would be very useful to anyone using an AnimatedSprite with multiple animations where the offsets are different for different animations.

EDIT:

The workaround actually does not work. Since frame_changed is called AFTER the frame has changed, the first frame will be played with the previous animations offsets. So the sprite "jumps" for a frame as the second frame is played with the correct offsets.

EDIT 2:

New workaround by overriding the "play" function. Works like it should. Still requires me to hardcode offsets which is less than ideal.

@Calinou
Copy link
Member

Calinou commented Apr 3, 2020

Related to #94.

@Calinou Calinou changed the title Specify Offset Per Animation in AnimatedSprite Add a way to specify per-animation offsets to AnimatedSprite May 6, 2020
@elvisish
Copy link

elvisish commented Jan 5, 2024

I'd suggest this would be extremely useful for death animations, where the character will generally need more horizontal space for falling back compared running, jumping and idle animations. While it can be done with AnimationPlayer, it would make a lot more sense to allow specific animations have their own offsets in AnimatedSprite (this could be added on in addition to the global offset in the AnimatedSprite node).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants