0
\$\begingroup\$

I'm developing a game where I need to paint half of a image when the user is either wrong or right. To paint the image, I'm using setTint() to paint the image the color I need, but it paints the whole image, is there any way I can paint only half, using setTint or another method?

\$\endgroup\$
0
\$\begingroup\$

I'm unfamiliar with phaser, but a general way to achieve this is to create two Image objects, each one having half of the picture, and position the second below the first, so it looks like one complete image.

At the moment the user answers, you can use setTint() to change only half of the picture.

This method has its limitations, as you can't dynamically split an image to more parts this way, but it is a simple method that gets the desired result.

\$\endgroup\$
3
  • \$\begingroup\$ Yean, I was trying to avoid this, because i have a lot of images to apply this, but I think i'll have to use this method. But I'll keep looking for something else, if I find I'll post here! Thanks so much man, have a really nice day! \$\endgroup\$ Jan 16 '20 at 11:20
  • \$\begingroup\$ @ArthurOliveira You can also do the same thing by using shaders, which can be more automated, but I'm not familiar enough with phaser to know how it handles them. \$\endgroup\$
    – TomTsagk
    Jan 16 '20 at 11:40
  • \$\begingroup\$ I don't know much about shaders, but for sure I'll look for and try to use it. Thanks so much man!! \$\endgroup\$ Jan 16 '20 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.