azerion / phaser-spine

A plugin for Phaser 2 that adds Spine support
MIT License
121 stars 57 forks source link

Don't really get how the scaling works #22

Closed Skeptron closed 7 years ago

Skeptron commented 7 years ago

Hi everyone!

I'm having an issue with the scaling here : I think I'm following the doc carefully but the result is not what I expected.

Here is my code :

// In the preload() method
this.game.load.spine('char', "img/char.json", ["@0.25x"]);

// In the create() method
let char = this.game.add.spine(400, 800, "char");
char.setAnimationByName(0, "idle", false);

I have 3 files :

As you might have guessed, I animated images 4 times too big in spine (just not to get blind, because original char is small), then exported the output 4 times smaller.

So I was expecting the plugin to understand that and make my char 4 times smaller ingame, but on the contrary it puts the char back to its 4-times-too-big size : it's really big and blurry (because images were shrunk 4 times, thus scaling them up by 4 makes them super blurry). Simply put, instead of understanding that char has been reduced by 4, the plugin tries to get it back to its original size.

Is that the correct behaviour? How could I accomplish my feature (that is, animating big sprites in Spine and exporting them to a smaller, final scale?).

Thanks a lot guys!

shibekin69 commented 7 years ago

Haven't used this type of scaling yet. But you can scale the phaser group making up the animation

Skeptron commented 7 years ago

Yes you can. I tried setting the scale to .25, and it works, but it's blurry. Doesn't feel right : according to the doc I shouldn't have to do that :(

AleBles commented 7 years ago

The scaling as defined in this library is assuming that only the png file is scaled so we are able to load in smaller asset files. The bones in the json still have their original sizes and will also be drawn with their original sizes.

In order to make the entire export smaller, you need to scale the rootbone before exporting (just checked with our Animator, and this works for him). If you leave the assets at the original size (no scaling) everything should look fairly crisp.

AleBles commented 7 years ago

@Skeptron, did this awnser your question?

Skeptron commented 7 years ago

Yeah thanks, found my way around this issue!