Open StreakingMan opened 1 year ago
You're not using it incorrectly. This appears to be a bug triggered by adding a physics component. I'm not super familiar with that Phaser sub-system, so I'm not sure what's going wrong. I'll update the issue once I've figured it out.
In Phaser, if you use arcade
physics and set the scaleX
to a negative number will result in having the physics body reflected regardless on the usage of a SpineGameObject or a normal GameObject.
It's possible to get the very same result of the video on this phaser playground example adding block.scaleX = -block.scaleX;
as latest line of the create
function. The debug bounding box is reflected on the right of the brown box:
We have to consider that to flip a GameObject in Phaser, it seems that there are flip methods. In this case the setFlipX(boolean)
should be used.
It's important to notice this part of the Phaser flip documentation:
If this Game Object has a physics body, it will not change the body. This is a rendering toggle only.
So in general it's the user that has to take care of the GameObject body position for some operation (such as rotation) on the GameObject - at least for arcade
physics.
However, when using setFlipX(boolean)
on a SpineGameObject, it is not flipped. We should do that probably and will make a fix to it.
In any case, my advice is to explore also the matter
physics system. That is definitely more advanced and your use case would work out of the box.
Indeed, scaling with negative numbers in matter
won't produce the effect of reflecting the GameObject body.
@davidetan Thank you for your reply, I have tried the matter
physics system, scaling with negative numbers works correctly, but the bounds position is still not right since the initiation.
I have tried using setOrigin
and providing a custom bounds provider, but it doesn't work. I'm struggling where the problem is, Here's the code:
Here's my test of the mix-and-match-example.html, which has left me confused:
https://github.com/EsotericSoftware/spine-runtimes/assets/30397306/79b898ea-45c3-4adf-a2e7-4286b5f61f13
What I did was add physics and use scaleX=-1 to turn left.
Is there something wrong with the Spine source file, or am I using scaleX incorrectly?