UtilApi class

API with general helper functions available in every GameComponent.

Access it through the util object:

component.util.showDamage(10);
component.util.getDirectionToTarget(enemy);
component.util.generateValues(...);

Constructors

UtilApi(GameComponent comp)

Properties

bottom double
Bottom edge of the component.
no setter
comp GameComponent
final
hashCode int
The hash code for this object.
no setterinherited
left double
Left edge of the component.
no setter
playerRect Rect
Gets player position used how base in calculations.
no setter
Right edge of the component.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
top double
Top edge of the component.
no setter

Methods

addParticle(Particle particle, {Vector2? position, Vector2? size, Vector2? scale, double? angle, Anchor? anchor, int? priority, ComponentKey? key}) → void
Used to add particles in your component.
directionThePlayerIsIn() Direction?
generateValues(Duration duration, {double begin = 0.0, double end = 1.0, Curve curve = Curves.linear, Curve? reverseCurve, bool autoStart = true, bool infinite = false, VoidCallback? onFinish, ValueChanged<double>? onChange}) ValueGeneratorComponent
Used to generate numbers to create your animations or anythings.
getAngleToPlayer() double
Get angle between this comp and player (player as base).
getAngleToTarget(GameComponent target) double
Get angle between this comp to target.
getDirectionToPlayer() Direction?
Gives the direction of the player in relation to this component.
getDirectionToTarget(GameComponent target, {bool withDiagonal = true}) Direction
Get direction between this comp to target.
getInverseAngleToPlayer() double
Get angle between this comp and player (this comp position as base).
globalToViewportPosition(Offset position) Offset
isCloseTo(GameComponent target, {double distance = 5}) bool
Checks if this component is close to target.
loadCameraParallaxComponent(Iterable<ParallaxData> dataList, {Vector2? baseVelocity, Vector2? velocityMultiplierDelta, ImageRepeat repeat = ImageRepeat.repeatX, Alignment alignment = Alignment.bottomLeft, LayerFill fill = LayerFill.height, Images? images, Vector2? position, Vector2? size, Vector2? scale, double? angle, Anchor? anchor, int? priority, FilterQuality? filterQuality, ComponentKey? key}) Future<ParallaxComponent<FlameGame<World>>>
loadParallaxComponent(Iterable<ParallaxData> dataList, {Vector2? baseVelocity, Vector2? velocityMultiplierDelta, ImageRepeat repeat = ImageRepeat.repeatX, Alignment alignment = Alignment.bottomLeft, LayerFill fill = LayerFill.height, Images? images, Vector2? position, Vector2? size, Vector2? scale, double? angle, Anchor? anchor, int? priority, FilterQuality? filterQuality, ComponentKey? key}) Future<ParallaxComponent<FlameGame<World>>>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
overlaps(Rect other) bool
Checks if this component overlaps the other rect.
showDamage(double damage, {TextStyle? config, double initVelocityVertical = -5, double initVelocityHorizontal = 1, double gravity = 0.5, double maxDownSize = 20, DirectionTextDamage direction = DirectionTextDamage.RANDOM, bool onlyUp = false}) → void
Add in the game a text with animation representing damage received.
toString() String
A string representation of this object.
inherited
viewportPositionToGlobal(Offset position) Offset

Operators

operator ==(Object other) bool
The equality operator.
inherited