Best way to create a mask for a texture altas.

Hi,

For some sprites I have a texture with depth information to go along side the standard colour texture which have the exact same frame positions and sizes. These sprites are combined as parts to a compound sprite and these parts can be both in front and behind other parts during animations and the depth maps are used to dynamically generate another texture which will contain mask information for each frame. These masks are generated once and are only regenerated when overlapping parts change.

The question I have is how can I best apply this mask texture to the texture atlas? For example, If the animation is on frame 6, how can I have the sprite use frame 6 of the mask texture? The most basic thing I can think to do would be to grab the frame image and call setMask() on the sprite each frame, but I’m not sure of the performance implications of this.

Is there a way to set the mask for the entire atlas which the sprite can use each frame? If not, what would be an efficient way to approach this?

:wave:

I don’t think you have to change masks. Just call setFrame() on the mask source.