-
- All Implemented Interfaces:
public final class ConfettiConfetti holds all data to the current state of the particle Each frame update triggers the
rendermethod, which recalculates the particle's properties based on its current state.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classConfetti.Companion
-
Field Summary
Fields Modifier and Type Field Description private Floatrotationprivate Integeralphaprivate FloatscaleXprivate IntegeralphaColorprivate final BooleandrawParticleprivate Vectorlocationprivate final Floatwidthprivate final Shapeshapeprivate Longlifespanprivate final BooleanfadeOutprivate Vectorvelocityprivate Floatdampingprivate final FloatrotationSpeed3Dprivate final FloatrotationSpeed2Dprivate final FloatpixelDensity
-
Method Summary
Modifier and Type Method Description final FloatgetRotation()final UnitsetRotation(Float rotation)final IntegergetAlpha()final UnitsetAlpha(Integer alpha)final FloatgetScaleX()final UnitsetScaleX(Float scaleX)final IntegergetAlphaColor()The color of the particle with the current alpha value applied final UnitsetAlphaColor(Integer alphaColor)The color of the particle with the current alpha value applied final BooleangetDrawParticle()Determines whether the particle should be drawn. final VectorgetLocation()The current position of the particle as a Vector object that contains x and y coordinates. final UnitsetLocation(Vector location)The current position of the particle as a Vector object that contains x and y coordinates. final FloatgetWidth()The width of the particle in pixels. final ShapegetShape()The geometric shape of the particle. final LonggetLifespan()The duration the particle should exist for in milliseconds. final UnitsetLifespan(Long lifespan)The duration the particle should exist for in milliseconds. final BooleangetFadeOut()If true, the particle will gradually become transparent over its lifespan. final VectorgetVelocity()The current velocity of the particle. final UnitsetVelocity(Vector velocity)The current velocity of the particle. final FloatgetDamping()A factor that reduces the particle's velocity over time, simulating air resistance. final UnitsetDamping(Float damping)A factor that reduces the particle's velocity over time, simulating air resistance. final FloatgetRotationSpeed3D()The speed at which the particle rotates. final FloatgetRotationSpeed2D()The speed at which the particle rotates in 2D space. final FloatgetPixelDensity()The pixel density of the device's screen. final FloatgetSize()Returns the size of the particle in pixels final BooleanisDead()Checks if the particle is "dead", i.e. final UnitapplyForce(Vector force)Applies a force to the particle, which affects its acceleration final Unitrender(Float deltaTime, CoreRect drawArea)Updates the state of the particle for each frame of the animation. -
-
Method Detail
-
getRotation
final Float getRotation()
-
setRotation
final Unit setRotation(Float rotation)
-
getAlphaColor
final Integer getAlphaColor()
The color of the particle with the current alpha value applied
-
setAlphaColor
final Unit setAlphaColor(Integer alphaColor)
The color of the particle with the current alpha value applied
-
getDrawParticle
final Boolean getDrawParticle()
Determines whether the particle should be drawn. Set to false when the particle moves out of the view
-
getLocation
final Vector getLocation()
The current position of the particle as a Vector object that contains x and y coordinates.
-
setLocation
final Unit setLocation(Vector location)
The current position of the particle as a Vector object that contains x and y coordinates.
-
getLifespan
final Long getLifespan()
The duration the particle should exist for in milliseconds.
-
setLifespan
final Unit setLifespan(Long lifespan)
The duration the particle should exist for in milliseconds.
-
getFadeOut
final Boolean getFadeOut()
If true, the particle will gradually become transparent over its lifespan.
-
getVelocity
final Vector getVelocity()
The current velocity of the particle.
-
setVelocity
final Unit setVelocity(Vector velocity)
The current velocity of the particle.
-
getDamping
final Float getDamping()
A factor that reduces the particle's velocity over time, simulating air resistance. A higher damping value will slow down the particle faster.
-
setDamping
final Unit setDamping(Float damping)
A factor that reduces the particle's velocity over time, simulating air resistance. A higher damping value will slow down the particle faster.
-
getRotationSpeed3D
final Float getRotationSpeed3D()
The speed at which the particle rotates.
-
getRotationSpeed2D
final Float getRotationSpeed2D()
The speed at which the particle rotates in 2D space.
-
getPixelDensity
final Float getPixelDensity()
The pixel density of the device's screen. This is used to ensure that the particle's movement looks consistent across devices with different screen densities.
-
applyForce
final Unit applyForce(Vector force)
Applies a force to the particle, which affects its acceleration
-
-
-
-