I'm creating a live wallpaper using andengine. By using ColorParticleModifier, I can change the color of the particles. But how can I make them change color randomly by themselves?
Thank you!
I'm creating a live wallpaper using andengine. By using ColorParticleModifier, I can change the color of the particles. But how can I make them change color randomly by themselves?
Thank you!
If you want them to change color over time, you could create a new Particle class and Override onUpdate and place your color changing code in there. Doing this will allow you to have the particle change color every time onUpdate is run.
private float colorTimer = 0;
private final float COLOR_RESET = 0.25f; //change color 4 times per second
private Random rand = new Random();
...
@Override
protected void onUpdate(final float pSecondsElapsed){
colorTimer += pSecondsElapsed;
if (colorTimer >= COLOR_RESET){
colorTimer =0;
this.mEntity.setColor(rand.nextFloat(), rand.nextFloat(), rand.nextFloat());
}
super.onUpdate(pSecondsElapsed);
}