andengine - how to change particle color randomly? -
i'm creating live wallpaper using andengine. using colorparticlemodifier, can change color of particles. how can make them change color randomly themselves?
thank you!
if want them change color on time, create new particle class , override onupdate , place color changing code in there. doing allow have particle change color every time onupdate 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); }
Comments
Post a Comment