Change the tint of sprite intersection with tiled sprite?


I want to me able to change the color of a sprite, but only the part that is intersecting with a tiled sprite, and the portion of the tiled sprite that is not intersecting I want to hide.
Hopefully the above graphic points out how I want this to work.
Currently I can reduce the opacity of the tiled sprite to achieve this effect only halfway because the non-intersecting portion of the tiled sprite is still visible.
I tried looking at the “Masked Sprite” plugin, but it did not seem to work or I need help understanding how it could be used in this situation.
Thanks in advance for your ideas.

My thinking is to use the sprite mask. You’ll need 2 copies of the blue sprite though - one for blue and one for the recoloured sprite. The recoloured sprite would need to be placed at the same position as the blue sprite, and at a lower z-order. The mask would only be applicable to the blue sprite, and would hide the blue sprite where they overlap.

I think the blend mode event actions may do this for you. I believe multiply (mode 2) is the one you want.

Otherwise MrMen’s got the best alternative. 2 different colored sprites, one that is green (on top of the blue), and is masked by the tiled sprite. The tiled will be invisible, and the green will only be visible when it’s overlapped by the tiled sprite.

The multiply blend mode works, but only if the background behind the sprite is black.

For the masking, I need to mask several sprites using the same tiled sprite as the mask… the extension doesn’t support that… I tried adding it as well in the same way the painted shape was done… but alas no luck, it just ends up hiding all the sprites that are masked… perhaps the underlying renderer just doesn’t support using tiled sprites as a mask.

Not sure what you mean here, from your original description you only need to mask the green sprite with the tiled sprite. It just needs to be above the blue sprite and have their positions synced up.

The green sprite will only be visible when in collision with the tiled sprite, and will appear as if the blue sprite is changing color.

That said, if you actually have multiple different objects/object types, just use an object group for all of them, and use the group in the event.

Edit:

Sprite masking also seems to work fine for tiled sprites for me:

https://game-previews.gdevelop-app.com/1634659578067-904249/index.html

image

Keep in mind your tiled sprite really needs to be a solid color (and the closer to red the better) for it to work fully.