Using Vframes/Hframes causes rendered spritesheet to be shifted when picking frames for animation

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By buildingdown
:warning: Old Version Published before Godot 3 was released.

I have a spritesheet that is 32x32 pixels. I’m told that in order to use the AnimationPlayer, I have to set the vframes and hframes. But when I do this, each time I increase the frame by 11, the sprite will “shift up”.

Here is the sprite in question. The sprite is quite large, and is 384x4608 pixels total.

Here’s what I’ve done (with pictures!):

  1. On frame 0, I align the vframe/hframe until I see the image correctly display a single character

  2. Increase the frame, but the character starts to shift upwards every 11th frame until you see two characters inside the same grid.

  3. On the right you can see that each grid is 32x32 pixels, so the spritesheet (a snippet) itself is okay.

enter image description here

TLDR: Can someone explain:

  1. What is the correct vframe/hframe for this sheet?
  2. Why is this odd shifting happening?
  3. How do you correctly calculate the vframe/hframe for any sized image?

The texture is a bit large, try cutting it to the size you need (8x10 frames for a character) because going over 4096 could give some issues.

eons | 2017-03-11 02:31

:bust_in_silhouette: Reply From: aozasori

1) What is the correct vframe/hframe for this sheet?

Vframes: 4608 / 32 = 144
Hframes: 384 / 32 = 12

2) Why is this odd shifting happening?

Probably because Vframes is set to 130 when it should be 144. If it occurs when everything is apparently correct, it could mean the error is in the image itself (characters are offset from the 32x32 grid somewhere in the sheet).

3) How do you correctly calculate the vframe/hframe for any sized image?

Divide height/width of sheet by height/width of one frame to get vframes/hframes.

Aside, i agree with eons that you should probably think about cutting the texture into smaller parts.