Solved

Programmatically fade a color

Posted on 2013-02-07
3
679 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
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.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now