How to color overlay non transparent SKSpriteNode texture parts withs Swift

676 views Asked by At

I am making a isometric game using Swift and Sprite Kit. I am rethinking my approach about coloring buildings before they are build.

Like in every game, before user builds an object, he has to move it to the free plot, and by moving it, node will change color from green to red, if the object can or cannot be placed.

Here are some pictures for clarification:

enter image description here enter image description here

What I am doing right now, as i am prety new in Sprite Kit:

I make one SKNode - parent

I make 3 nodes and add them to a parent node. Those 3 nodes contain regular building image, red building image and green building image.

If building should be colored red, I hode nodes containing green and regular images. if it needs to be green, I hide other two and sme goes for regular.

My main question is this:

Can I have only regular node, with regular image, and somehow overlay it with green or red color (but only overlay non transparent image parts? I was thinking abut using Pixel Shader but I'm not sure if it's the right tool.

If I cannot do that my next question is: Is this 3 nodes in a parent approach a good one or it's better to change the image of one node, depending if I need to show regular green or red object image?

0

There are 0 answers