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

Commit 91d4fe6

Browse files
author
Thomas Orlando
authored
Merge pull request #3 from greghe/feature-bitmap-array-constructors
Adds two constructors to ParticleSystem that accept an array of bitmaps. Corresponds to Leonids pull request plattysoft#70.
2 parents 1c34cfa + f57fc92 commit 91d4fe6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

LeonidsLib/src/main/java/com/plattysoft/leonids/ParticleSystem.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,37 @@ public ParticleSystem(Activity a, int maxParticles, Bitmap bitmap, long timeToLi
218218
}
219219
}
220220

221+
/**
222+
* Utility constructor that receives an array of Bitmaps
223+
*
224+
* @param a The parent activity
225+
* @param maxParticles The maximum number of particles
226+
* @param bitmaps An array of bitmaps which will be randomly assigned to particles
227+
* @param timeToLive The time to live for the particles
228+
* @param parentViewId The view Id for the parent of the particle system
229+
*/
230+
public ParticleSystem(Activity a, int maxParticles, Bitmap[] bitmaps, long timeToLive, int parentViewId) {
231+
this((ViewGroup) a.findViewById(parentViewId), maxParticles, timeToLive);
232+
for (int i=0; i<mMaxParticles; i++) {
233+
mParticles.add (new Particle (bitmaps[mRandom.nextInt(bitmaps.length)]));
234+
}
235+
}
236+
237+
/**
238+
* Utility constructor that receives an array of Bitmaps
239+
*
240+
* @param parentView The parent view group
241+
* @param maxParticles The maximum number of particles
242+
* @param bitmaps An array of bitmaps which will be randomly assigned to particles
243+
* @param timeToLive The time to live for the particles
244+
*/
245+
public ParticleSystem(ViewGroup parentView, int maxParticles, Bitmap[] bitmaps, long timeToLive) {
246+
this(parentView, maxParticles, timeToLive);
247+
for (int i=0; i<mMaxParticles; i++) {
248+
mParticles.add (new Particle (bitmaps[mRandom.nextInt(bitmaps.length)]));
249+
}
250+
}
251+
221252
/**
222253
* Utility constructor that receives an AnimationDrawable
223254
*

0 commit comments

Comments
 (0)