class: Comet
[39:7] extends: object
A small comet that arcs across the AGR FXGL window. Build one and call run(). The comet enters at a random point on one edge and heads for a random point on a different edge, bowing left or right of that line as it flies. Every value is drawn fresh, so no two comets fly the same path. The numbers at the top of the class are the dials. Change them to alter how the comet looks and flies.
Members
- minRadius
- maxRadius
- minSpeed
- maxSpeed
- minBow
- maxBow
- trailCount
- trailGap
- trailOpacity
- headColor
- trailColor
- glowLevel
Methods
-
run ()
Sends the comet across the window. It removes itself from the game world once it is off screen. Only works inside AGR, which has the FXGL game already running.
- @r
Entity- the comet, already attached to the game world.
- @r
-
edgePoint (
int Edge, double Width, double Height)Picks a random point along one edge of the window. Points stay a tenth of the way in from each corner, so a comet crossing to a neighbouring edge still covers a useful stretch of window instead of clipping the corner.
- @p
Edgeis the edge: 0 top, 1 right, 2 bottom, 3 left. - @p
Widthis the window width in pixels. - @p
Heightis the window height in pixels. - @r
list- the point as [x, y], both doubles.
- @p
-
tailLength (
double Radius)How far the trail reaches behind the head.
- @p
Radiusis the head radius in pixels. - @r
double- the tail length in pixels.
- @p
-
buildView (
double Radius)Builds the comet's look: a bright head at the local origin, with shrinking and fading circles trailing along local -X, all under a glow. The projectile component turns the entity to face the way it is travelling, which points local +X forward, so the tail stays behind the head right round the arc.
- @p
Radiusis the head radius in pixels. - @r
Group- the comet's view node.
- @p