PulsatingFloat.java :  » Game » agameframework » com » agameframework » utils » Android Open Source

Android Open Source » Game » agameframework 
agameframework » com » agameframework » utils » PulsatingFloat.java
package com.agameframework.utils;

import com.agameframework.interfaces.IUpdatable;

public class PulsatingFloat implements IUpdatable{

  private Float mCurrentValue;
  private float mDirection;
  private float mSpeed;
  private float mMin;
  private float mMax;

  public PulsatingFloat(Float pulsingValue, float direction, float speed, float min, float max)
  {
    this.mCurrentValue = pulsingValue;
    this.mDirection = direction;
    this.mSpeed = speed;
    this.mMin = min;
    this.mMax = max;
  }
  
  public PulsatingFloat(float direction, float speed, float min, float max)
  {
    this.mCurrentValue = new Float(0.5f);
    this.mDirection = direction;
    this.mSpeed = speed;
    this.mMin = min;
    this.mMax = max;
  }
  
  public void update()
  {
    if (mCurrentValue <= mMin)
    {
      mDirection = 1;
    }
    if (mCurrentValue >= mMax)
    {
      mDirection = -1;
    }

     mCurrentValue += mDirection * mSpeed;

    if (mCurrentValue > mMax)
    {
      mCurrentValue = mMax;
    }
    else if (mCurrentValue < mMin)
    {
      mCurrentValue = mMin;
    }
  }
  
  public float getDirection() {
    return mDirection;
  }

  public void setDirection(float direction) {
    this.mDirection = direction;
  }

  public float getSpeed() {
    return mSpeed;
  }

  public void setSpeed(float speed) {
    this.mSpeed = speed;
  }

  public float getMax() {
    return mMax;
  }

  public void setMax(float max) {
    this.mMax = max;
  }

  public float getMin() {
    return mMin;
  }

  public void setMin(float min) {
    this.mMin = min;
  }

  public Float getCurrentValue() {
    return mCurrentValue;
  }

  public void setCurrentValue(Float currentValue) {
    this.mCurrentValue = currentValue;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.