Solved

Programmatically fade a color

Posted on 2013-02-07
3
681 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
moto 4g plus phone apps 5 53
maven not picking latest jar instead picking old jar from .m2 12 50
JDBC performance 8 29
Java array 21 88
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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…
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.

730 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