Solved

Programmatically fade a color

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

808 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