Solved

Programmatically fade a color

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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…
This video teaches viewers about errors in exception handling.

691 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