Skip to content

Commit

Permalink
config methods return a ParticleSystem so they can be chained.
Browse files Browse the repository at this point in the history
  • Loading branch information
plattysoft committed May 23, 2014
1 parent cf979c9 commit 919dca3
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions LeonidasLib/src/com/plattysoft/leonids/ParticleSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,38 @@ public ParticleSystem(Activity a, int maxParticles, Bitmap bitmap) {
}
}

public void setSpeed(float speed) {
setSpeedRange(speed, speed);
public ParticleSystem setSpeed(float speed) {
return setSpeedRange(speed, speed);
}

public void setSpeedRange(float speedMin, float speedMax) {
public ParticleSystem setSpeedRange(float speedMin, float speedMax) {
mSpeedMin = speedMin;
mSpeedMax = speedMax;
return this;
}

public void setAngleRange(int minAngle, int maxAngle) {
public ParticleSystem setAngleRange(int minAngle, int maxAngle) {
mMinAngle = minAngle;
mMaxAngle = maxAngle;
return this;
}

public void setScaleRange(float minScale, float maxScale) {
public ParticleSystem setScaleRange(float minScale, float maxScale) {
mMinScale = minScale;
mMaxScale = maxScale;
return this;
}

public void setRotationSpeed(float minRotationSpeed, float maxRotationSpeed) {
public ParticleSystem setRotationSpeed(float minRotationSpeed, float maxRotationSpeed) {
mMinRotation = minRotationSpeed;
mMaxRotation = maxRotationSpeed;
return this;
}

public void setVelocity(float velocity, float angle) {
public ParticleSystem setVelocity(float velocity, float angle) {
mVelocity = velocity;
mVelocityAngle = angle;
return this;
}

/**
Expand All @@ -100,18 +105,19 @@ public void setVelocity(float velocity, float angle) {
* @param duration fade out duration in miliseconds
* @param interpolator the interpolator for the fade out (default is linear)
*/
public void setFadeOut(long milisecondsBeforeEnd, Interpolator interpolator) {
public ParticleSystem setFadeOut(long milisecondsBeforeEnd, Interpolator interpolator) {
mMilisecondsBeforeEnd = milisecondsBeforeEnd;
mFadeOutInterpolator = interpolator;
return this;
}

/**
* Configures a fade out for the particles when they disappear
*
* @param duration fade out duration in miliseconds
*/
public void setFadeOut(long duration) {
setFadeOut(duration, new LinearInterpolator());
public ParticleSystem setFadeOut(long duration) {
return setFadeOut(duration, new LinearInterpolator());
}

/**
Expand Down

0 comments on commit 919dca3

Please sign in to comment.