- Home /
How to crossfade sprites with overlaid sprites
I'm sure there must be a simple way to do this. I'm trying to crossfade between two sprites which have overlaid children sprites on top of them in a 2D game. If I was only trying to crossfade the background, parent sprites, I'd be happy with the effect of simply setting alpha on them and transitioning across.
However attempting to do that by simply setting the alpha on the background and child sprites results in the background area of the parent sprite being visible as the fade is progressing, and the fading object having greater opacity in the overlaid area. Ideally it would appear as though the child sprites are part of the parent sprites which are then faded out (or in) as one object. Apart from a border background area on which there are no child sprites both the background and child textures are fully opaque.
The child sprites aren't always present, they are turned on and off based on game logic which occurs outside of the scene this problem occurs in.
I've tried (a workaround?) removing all the child sprite areas from the parent sprite and instead using two different sprites to fill the hole for the two states, but ended up with some type of pixel rounding issues on some devices resulting in gaps or overlays on the texture borders. This may still be the way to go but it seems like a long way around.
The solution is for mobile and needs to work on an iPad 2+.
I imagine shader tricks may be the solution to this, unfortunately I know fairly little about them. Thanks for any help!
Your answer
Follow this Question
Related Questions
Sprite not visible from behind 0 Answers
ShaderGraph Position from Texture Sample Issue 0 Answers
Shader sprite overlay other sprites 0 Answers
"Blend SrcFactor DstFactor, SrcFactorA DstFactorA" Does not work 2 Answers
Sprite masking 3 Answers