?
Solved

Programmatically fade a color

Posted on 2013-02-07
3
Medium Priority
?
683 Views
Last Modified: 2013-02-07
I need to fade a color. The color is of a Sprite in AndEngine. Color values are from 0 .. 1 (not 256). So each time I subtract 0.2. This has the effect of darkening. How do I change the colors to fade?

The code below loops 5 times.
import org.andengine.entity.sprite.Sprite;
import org.andengine.util.color.Color;
...
// loop
Color color = sprite.getColor();
Color newColor = new Color(color.getRed()- 0.20f, color.getBlue()- 0.20f, color.getGreen()- 0.20f);
sprite.setColor(newColor);
// end loop

Open in new window

0
Comment
Question by:allelopath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 38864381
Add 0.2f?
0
 
LVL 1

Author Comment

by:allelopath
ID: 38865834
Nope. Its not color at all, but rather alpha (get/set).
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38865880
The alpha level?
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, people trade privacy and security for convenience. However in today's concrete jungle, this is an extremely foolish decision considering the vast amount of technologies being used against consumer interest. First off, I won't waste any time e…
A short article about problems I had with the new location API and permissions in Marshmallow
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question