2
\$\begingroup\$

I have a game with a HUD which is drawn by fillrectangle.

How would I fade these rectangles when the player is on the HUD?

\$\endgroup\$
2
  • \$\begingroup\$ What do you mean by fade? Do you want the objects to retain a specific opacity? Or do you want the fillrectangle to visually fade out in a specified amount of time? \$\endgroup\$
    – jgallant
    Commented Jul 20, 2016 at 17:56
  • 4
    \$\begingroup\$ Stack overflow question with answer: stackoverflow.com/questions/8110975/… \$\endgroup\$ Commented Jul 20, 2016 at 18:03

1 Answer 1

1
\$\begingroup\$

You can start a new thread, create a loop inside, and invoke this every few ms:

// decalre a golbal int i
i = (i + 1) % 0xFF
Color color = new Color(i, [your color], [your color], [your color]);
g.setColor(myColour); // graphics context object

And you'll see your canvas fading.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .