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?

  • \$\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 Jul 20 '16 at 17:56
  • 4
    \$\begingroup\$ Stack overflow question with answer: stackoverflow.com/questions/8110975/… \$\endgroup\$ – Quintin Steiner Jul 20 '16 at 18:03

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.


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.