Android Open Source - fireflies_android Firefly Sprite






From Project

Back to project page fireflies_android.

License

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.

Java Source Code

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;

       }
        
    }
  }
}




Java Source Code List

com.donothingbox.fireflies_android.CoreApp.java
com.donothingbox.fireflies_android.DynamicActivity.java
com.donothingbox.fireflies_android.GameSurfaceActivity.java
com.donothingbox.fireflies_android.MainActivity.java
donothingbox.game.controller.AudioController.java
donothingbox.game.controller.GameThread.java
donothingbox.game.controller.HUDController.java
donothingbox.game.controller.StateController.java
donothingbox.game.model.DepthSortComparator.java
donothingbox.game.utils.BitmapUtils.java
donothingbox.game.utils.Utils.java
donothingbox.game.view.CustomDrawableView.java
donothingbox.game.view.FireflySprite.java
donothingbox.game.view.GameLayout.java
donothingbox.game.view.GameSurfaceView.java
donothingbox.game.view.Sprite.java