Let’s say I have a png representing sprite sheet with non-uniform widths of individual frames.
I slice the spritesheet and then use TexturePacker
Now, when I do the initiation of new sprite, set the sequence and run it, the sprite jitters.
I assume it is because of the various frame widths.
I can imagine the solution could be that I can find the widest frame, and change the width of other frames to that width, and then pack it with TexturePacker. The problem is, that one has to “widen” the frames in correct way - see following example:
I have two frames showing fireball heading right, one is 5 units wide, the other one 3 units wide.
1st: |XXXXX| 2nd: |YYY|
When I want to make the 2nd one 5 units wide, I have to make it same width as 1st (Step 1), and put the content of the original frame to correct position - in this case, to the right side of the frame (Step 2). If omitting Step 2, the final animation would look strange, because the fireball has its “nose” 5 units to the right when playing 1st frame, but back to 3 (even though the frame now also 5 units wide) when playing 2nd frame - this causes the jitter.
So, I have to perform both steps:
Step 1: 2nd: | | Step 2: 2nd: | YYY|
Now, the frames have uniform width and the content is aligned well.
However, this seem like ton of work - especially when having many frames.
Any idea about better approach?