phaser
phaser copied to clipboard
Spine gameobject setAlpha() broken
Version
- Phaser Version: 3.60 + spine plugins 3.8 & 4.1
Description
There appears to be a problem with spine alpha inheritance from container. Although the spine does eventually respect the parent container's alpha, it doesn't follow the standard procedure like other gameobjects (GO's) and results in wasted failed processing every render cycle.
During render cycle, ContainerWebGLRenderer() will temporarily set the GO's alpha before rendering and revert it afterwards with calls to the GO's setAlpha()
setAlpha() is called with 4 parameters (topLeft, topRight, bottomLeft, bottomRight) with the intention that the GO will just use the 'topLeft' value if it doesn't support per corner alpha, or if no 'topRight' is passed then 'topLeft' is used for all alpha.
The spine GO's (both 3.8 and 4.1) provide their own setAlpha() which has parameters (value, slotName), this results in an attempt to look up a slot name based on becauase the 'slotName' argument holds the 'topRight' value (if not 0), the look up fails and sets nothing.
In spite of this failure to set the GO alpha, the spine renderer grabs the parent alpha and uses it.
The question is, as this has gone on for a while, should it be fixed or let sleeping dogs lie?
Additional Information
The fix would be to change the GO's setAlpha() to only use the 1st parameter as alpha and then also in the renderer to stop using use the parent alpha as the GO alpha will now be correct.
This fix would save 2 failed slot name lookups per render and make setAlpha() behave and be used as expected. It would introduce a breaking change as setAlpha() would no longer handle slots - or as I suspect, maybe it was never meant to as it's not included in docs - but a new better named setSlotAlpha() could be added if needed.