Back to project page fireflies_android.
The source code is released under:
MIT License
If you think the Android project fireflies_android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package donothingbox.game.view; /*from w w w .j a v a 2s . c o m*/ import java.util.Random; import android.graphics.Bitmap; public class FireflySprite extends Sprite{ public float alphaChange = 1; private Boolean isDimming = true; private Boolean isHidden = false; public Boolean isActive = true; public FireflySprite(Bitmap bitmap) { super(bitmap); // TODO Auto-generated constructor stub } public void updateGraphic(){ if(!isHidden) { if(isDimming) { if(this.getAlpha()<=0) { isDimming = false; isHidden = true; //visible = false; } this.setAlpha(getAlpha()-alphaChange); } else { if(this.getAlpha()>=100) isDimming = true; this.setAlpha(getAlpha()+alphaChange); } } else { Random rand = new Random(); if( (rand.nextFloat() * (2000 - 0) + 0) >1950) { isHidden = false; visible = true; } } } }