You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there something wrong with the Spine source file, or am I using scaleX incorrectly?
The text was updated successfully, but these errors were encountered:
StreakingMan
changed the title
spine-phaser: bounds not correct while using physics and scaleX -1
[spine-phaser] bounds not correct while using physics and scaleX -1
Nov 23, 2023
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.
Here's my test of the mix-and-match-example.html, which has left me confused:
2023-11-23.22.47.23.mov
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?
The text was updated successfully, but these errors were encountered: