Skip to content

Commit

Permalink
add new constructor allowing multiple image sources
Browse files Browse the repository at this point in the history
  • Loading branch information
jennaharris7 committed Oct 26, 2018
1 parent 4f2b425 commit 886b1a4
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,37 @@ public void run() {
}
}

/**
* 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)]));
}
}

private ParticleSystem(ViewGroup parentView, int maxParticles, long timeToLive) {
mRandom = new Random();
mParentLocation = new int[2];
Expand Down

0 comments on commit 886b1a4

Please sign in to comment.