I had an Idea of a game some time ago and I had no idea on how to do it with the language I was using, and now since I have started using Godot I though it might be more possible. So this is a clicker game where you don't actually click, but swipe to peel potatoes. The potato would have a texture on it (already not quite sure how to do that, if my potato texture is a square how would I make it not go off the potato?), and swiping on it would remove that texture where you swiped and you could see the plain color under, pretty much like in real life when you peel potatoes. But how would I make parts of that image texture disappear? Hopefully that's clear and someone can help me. Thanks in advance for any ideas!
How would I draw to reveal an image?
- Best Answerset by nanto2016
You might be able to use a color mask and use a shader. I wrote a tutorial for it with Godot 3 but it was quite awhile ago so it may need some adjusting: https://randommomentania.com/2019/07/godot-color-mask-tutorial/
- Edited
TwistedTwigleg Thanks a lot! This works just fine, though this is for Godot 3.1.1 so I made the necessary changes for it to work in Godot 4: I changed hint_color
to source_color
and did what the error told me to do, I added uniform sampler2D SCREEN_TEXTURE: hint_screen_texture, filter_linear_mipmap;
at the top of my code.
Edit: Oh! I just made a discovery: "clip children" actually works! I tried it out before but it didn't work, because I used a Control node instead of a ColorRect, and now it simply works! Thank you anyways, but this is way simpler (the option clip children is in the Visibility tab of any node, and then any children of that node will not appear where the parent is transparent).
No disrespect intended but the game concept's a bit er, unoriginal and has been done before.