Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #3 from greghe/feature-bitmap-array-constructors
Browse files Browse the repository at this point in the history
Adds two constructors to ParticleSystem that accept an array of bitmaps.
Corresponds to Leonids pull request plattysoft#70.
  • Loading branch information
Thomas Orlando authored May 11, 2020
2 parents 1c34cfa + f57fc92 commit 91d4fe6
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,37 @@ public ParticleSystem(Activity a, int maxParticles, Bitmap bitmap, long timeToLi
}
}

/**
* Utility constructor that receives an array of Bitmaps
*
* @param a The parent activity
* @param maxParticles The maximum number of particles
* @param bitmaps An array of bitmaps which will be randomly assigned to particles
* @param timeToLive The time to live for the particles
* @param parentViewId The view Id for the parent of the particle system
*/
public ParticleSystem(Activity a, int maxParticles, Bitmap[] bitmaps, long timeToLive, int parentViewId) {
this((ViewGroup) a.findViewById(parentViewId), maxParticles, timeToLive);
for (int i=0; i<mMaxParticles; i++) {
mParticles.add (new Particle (bitmaps[mRandom.nextInt(bitmaps.length)]));
}
}

/**
* Utility constructor that receives an array of Bitmaps
*
* @param parentView The parent view group
* @param maxParticles The maximum number of particles
* @param bitmaps An array of bitmaps which will be randomly assigned to particles
* @param timeToLive The time to live for the particles
*/
public ParticleSystem(ViewGroup parentView, int maxParticles, Bitmap[] bitmaps, long timeToLive) {
this(parentView, maxParticles, timeToLive);
for (int i=0; i<mMaxParticles; i++) {
mParticles.add (new Particle (bitmaps[mRandom.nextInt(bitmaps.length)]));
}
}

/**
* Utility constructor that receives an AnimationDrawable
*
Expand Down

0 comments on commit 91d4fe6

Please sign in to comment.