class: Fireworks
[41:7] extends: object
A display of fireworks across the AGR FXGL window. Build one and call run(). Several shells go off at random points in the upper part of the window, spread over a couple of seconds. Each throws out a ring of coloured sparks that arc away, fall under gravity, and fade to nothing the way a real firework does. The numbers at the top of the class are the dials. Change them to alter the display.
Members
- burstCount
- spread
- minSparkSpeed
- maxSparkSpeed
- minLife
- maxLife
- sparkCount
- minSparkSize
- maxSparkSize
- gravity
- colors
- shells
- nextShell
- sparkSeconds
Methods
-
run ()
Sets off the display. Every shell is worked out now and put on a timer; they go off over the next couple of seconds. Each burst clears itself out of the game world once its last spark has burned out. Only works inside AGR, which has the FXGL game already running.
- @r
int- the number of bursts set off.
- @r
-
fireNext ()
Sets off the next shell on the list. The timer calls this once per shell, so each call takes the next one along.
- @r
thisobject
- @r
-
sparkLife (
Index)FXGL asks how long each spark should burn as it spawns it.
- @p
Indexis the spark's number within the burst. - @r
AJavaFX Duration.
- @p
-
sparkPull ()
FXGL asks for the pull on the sparks once per tick. A steady downward pull is what makes the ring arc over and fall.
- @r
AJavaFX Point2D.
- @r
-
burst (
double X, double Y, string SparkColor, int SparkSpeed)Sets off one burst: a ring of sparks in a single colour that fall and fade out. The sparks belong to the emitter, so the entity only has to outlive the longest burning one.
- @p
Xis the burst's horizontal position in pixels. - @p
Yis the burst's vertical position in pixels. - @p
SparkColoris the spark colour as a web hex string. - @p
SparkSpeedis how fast the sparks start out, in pixels per second. - @r
Entity- the burst, already attached to the game world.
- @p