Can I set sprite transparency

Use sprite to set transparency for different sprites.
https://doc.babylonjs.com/typedoc/classes/babylon.sprite#
No attribute to set transparency was found

Hi, Not sure of your question. You want to use a sprite to set the transparency on other sprites?
Sounds a bit strange. Sprites take transparency from the texture (in png). I don’t know about using a sprite to set transparency on another sprite. In fact, I don’t understand it at all (sry).

1 Like

There is such a requirement. For example, there are 20 sprites. Click one to set the transparency of other sprites to 0.5 and the current one to 1, which mainly highlights the effect of the currently clicked sprites

OK, so ‘transparency’ means transparent. I believe what you want with your value of 0.5 is alpha/alpha blending. I am not sure of how you can change the alpha from the texture of a picked sprite within the same manager. I will let someone else answer this.
However, one thing I can think of is to use cellID (same as for an animation). On cellID 0(zero) have your opaque sprite, on cellID 1 (one) have a PNG with a 50% transparency. On pick, change the cellID(s)

Yes, I also thought of this method at first, but the pictures will be cumbersome

you can use the color property of each sprites: sprite.color.a = 0.5 for instance. Is this not working ?

2 Likes

yes,good :joy: