components library

Classes

Aabb2
Defines a 2-dimensional axis-aligned bounding box between a min and a max position.
Aabb3
Defines a 3-dimensional axis-aligned bounding box between a min and a max position.
AdvancedButtonComponent
The AdvancedButtonComponent has different skins for different button states. The defaultSkin must be added to the constructor or if you are inheriting - defined in the onLod method.
Anchor
Represents a relative position inside some 2D object with a rectangular size or bounding box.
Block
This is just a pair of <int, int>.
CameraComponent
CameraComponent is a component through which a World is observed.
CircleComponent
ClipComponent
A component that will clip its content.
Component
Components are the basic building blocks for a FlameGame.
ComponentKey
A key that can be used to identify a component and later retrieve it from its FlameGame ancestor.
ComponentSet
This is a simple wrapper over QueryableOrderedSet to be used by Component.
ComponentsNotifier<T extends Component>
A ChangeNotifier that notifies its listeners when a Component is added or removed, or updated. The meaning of an updated component will vary depending on the component implementation, this is something defined and executed by the component itself.
CoordinateTransform
Interface to be implemented by components that perform a coordinate change.
CustomPainterComponent
A PositionComponent that renders a CustomPainter at the designated position, scaled to have the designated size and rotated to the specified angle.
FpsComponent
The FpsComponent is a non-visual component which you can get the current fps of the game with by calling fps, once the component has been added to the component tree.
FpsTextComponent<T extends TextRenderer>
The FpsTextComponent is a TextComponent that writes out the current FPS. It has a FpsComponent as a child which does the actual calculations.
Frustum
Defines a frustum constructed out of six Planes.
IntersectionResult
Defines a result of an intersection test.
IsometricTileMapComponent
This component renders a tilemap, represented by an int matrix, given a tileset, in which the integers are the block ids.
JoystickComponent
KeyboardListenerComponent
A Component that receives keyboard input and executes registered methods. This component is based on KeyboardHandler, which requires the FlameGame which is used to be mixed with HasKeyboardHandlerComponents.
Matrix2
2D Matrix. Values are stored in column major order.
Matrix3
3D Matrix. Values are stored in column major order.
Matrix4
4D Matrix. Values are stored in column major order.
NineTileBox
This allows you to create a rectangle textured with a 9-sliced image.
NineTileBoxComponent
This class is a thin wrapper on top of NineTileBox as a component.
Obb3
Defines a 3-dimensional oriented bounding box defined with a center, halfExtents and axes.
ParallaxComponent<T extends FlameGame<World>>
A full parallax, several layers of images drawn out on the screen and each layer moves with different velocities to give an effect of depth.
ParticleSystemComponent
A PositionComponent that renders a Particle at the designated position, scaled to have the designated size and rotated to the specified angle.
Plane
PolygonComponent
PositionComponent
A Component implementation that represents an object that can be freely moved around the screen, rotated, and scaled.
Quad
Defines a quad by four points.
Quaternion
Defines a Quaternion (a four-dimensional vector) for efficient rotation calculations.
Ray
Defines a Ray by an origin and a direction.
RectangleComponent
ScreenHitbox<T extends FlameGame<World>>
This component is used to detect hitboxes colliding into the edges of the viewport of the game.
ScrollTextBoxComponent<T extends TextRenderer>
ScrollTextBoxComponent configures the layout and interactivity of a scrollable text box. It focuses on the box's size, scrolling mechanics, padding, and alignment, contrasting with TextRenderer, which handles text appearance like font and color.
ShapeComponent
A shape can represent any geometrical shape with optionally a size, position and angle. It can also have an anchor if it shouldn't be rotated around its center. A point can be determined to be within of outside of a shape.
SimplexNoise
SpawnComponent
The SpawnComponent is a non-visual component which can spawn PositionComponents randomly within a set area. If area is not set it will use the size of the nearest ancestor that provides a size. period will set the static time interval for when it will spawn new components. If you want to use a non static time interval, use the SpawnComponent.periodRange constructor. If you want to set the position of the spawned components yourself inside of the factory, set selfPositioning to true.
Sphere
Defines a sphere with a center and a radius.
Sprite
A Sprite is a region of an Image that can be rendered in the Canvas.
SpriteAnimation
Represents a sprite animation, that is, a list of sprites that change with time.
SpriteAnimationComponent
SpriteAnimationData
SpriteAnimationFrame
Represents a single sprite animation frame.
SpriteAnimationFrameData
SpriteAnimationGroupComponent<T>
SpriteBatchComponent
SpriteComponent
A PositionComponent that renders a single Sprite at the designated position, scaled to have the designated size and rotated to the specified angle.
SpriteGroupComponent<T>
A PositionComponent that can have multiple Sprites and render the one mapped with the current key.
TextBoxComponent<T extends TextRenderer>
TextBoxConfig
A set of configurations for the TextBoxComponent itself, as opposed to the TextRenderer, which contains the configuration for how to render the text only (font size, color, family, etc).
TextComponent<T extends TextRenderer>
TextElementComponent
TextPaint
TextPaint applies a Flutter TextStyle to a string of text, creating a TextPainterTextElement.
Timer
Simple utility class that helps handling time counting and implementing interval like events.
TimerComponent
A component that uses a Timer instance which you can react to when it has finished.
ToggleButtonComponent
The ToggleButtonComponent is an AdvancedButtonComponent that can switch between the selected and not selected state, imagine for example a switch widget or a tab that can be selected.
Triangle
Defines a triangle by three points.
Vector
Base class for vectors
Vector2
2D column vector.
Vector3
3D column vector.
Vector4
4D column vector.
World
The root component for all game world elements.

Mixins

ComponentViewportMargin<T extends FlameGame<World>>
The ComponentViewportMargin positions itself by a margin to the edge of the Viewport (or another parent with a size) instead of by an absolute position on the screen or on the game, so if the game is resized the component will move to keep its margin.
GestureHitboxes
This mixin can be used if you want to use hitboxes to determine whether a gesture is within the Component or not.
HasAncestor<T extends Component>
A mixin that ensures an ancestor is of the given type T.
HasCollisionDetection<B extends Broadphase<ShapeHitbox>>
Keeps track of all the ShapeHitboxs in the component's tree and initiates collision detection every tick.
HasDecorator
HasDecorator mixin adds a nullable decorator field to a Component. If this field is set, it will apply the visual effect encapsulated in this Decorator to the component. If the field is not set, then the component will be rendered normally.
HasGameRef<T extends FlameGame<World>>
HasGameRef mixin provides property game (or gameRef), which is the cached accessor for the top-level game instance.
HasGameReference<T extends FlameGame<World>>
HasGameReference mixin provides property game, which is the cached accessor for the top-level game instance.
HasGenericCollisionDetection<T extends Hitbox<T>, B extends Broadphase<T>>
This mixin is useful if you have written your own collision detection which isn't operating on ShapeHitbox since you can have any hitbox here.
HasPaint<T extends Object>
Adds a collection of paints and paint layers to a component
HasTimeScale
This mixin allows components to control their speed as compared to the normal speed. Only framerate independent logic will benefit from timeScale changes.
HasVisibility
A mixin that allows a component visibility to be toggled without removing it from the tree. Visibility affects the component and all it's children/descendants.
HasWorldReference<T extends World>
HasWorldReference mixin provides the world property, which is the cached accessor for the world instance that this component belongs to.
IgnoreEvents
This mixin allows a component and all it's descendants to ignore events.
KeyboardHandler
A Component mixin to add keyboard handling capability to components. Must be used in components that can only be added to games that are mixed with HasKeyboardHandlerComponents.
Notifier
Makes a component capable of notifying listeners of changes.
ParentIsA<T extends Component>
A mixin that ensures a parent is of the given type T.
SingleChildParticle
Implements basic behavior for nesting Particle instances into each other.
Snapshot
A mixin that enables caching a component and all its children. If renderSnapshot is set to true, the component and its children will be rendered to a cache. Subsequent renders use the cache, dramatically improving performance. This is only effective if the component and its children do not change - i.e. they are not animated and they do not move around relative to each other.

Constants

degrees2Radians → const double
Constant factor to convert and angle from degrees to radians.
radians2Degrees → const double
Constant factor to convert and angle from radians to degrees.

Functions

absoluteError(dynamic calculated, dynamic correct) double
Returns absolute error between calculated and correct. The type of calculated and correct must match and can be any vector, matrix, or quaternion.
buildPlaneVectors(Vector3 planeNormal, Vector3 u, Vector3 v) → void
Sets u and v to be two vectors orthogonal to each other and planeNormal.
catmullRom(double edge0, double edge1, double edge2, double edge3, double amount) double
Do a catmull rom spline interpolation with edge0, edge1, edge2 and edge3 by amount.
cross2(Vector2 x, Vector2 y) double
2D cross product. vec2 x vec2.
cross2A(double x, Vector2 y, Vector2 out) → void
2D cross product. double x vec2.
cross2B(Vector2 x, double y, Vector2 out) → void
2D cross product. vec2 x double.
cross3(Vector3 x, Vector3 y, Vector3 out) → void
3D Cross product.
degrees(double radians) double
Convert radians to degrees.
dot2(Vector2 x, Vector2 y) double
2D dot product.
dot3(Vector3 x, Vector3 y) double
3D dot product.
makeFrustumMatrix(double left, double right, double bottom, double top, double near, double far) Matrix4
Constructs a new OpenGL perspective projection matrix.
makeInfiniteMatrix(double fovYRadians, double aspectRatio, double zNear) Matrix4
Constructs a new OpenGL infinite projection matrix.
makeOrthographicMatrix(double left, double right, double bottom, double top, double near, double far) Matrix4
Constructs a new OpenGL orthographic projection matrix.
makePerspectiveMatrix(double fovYRadians, double aspectRatio, double zNear, double zFar) Matrix4
Constructs a new OpenGL perspective projection matrix.
makePlaneProjection(Vector3 planeNormal, Vector3 planePoint) Matrix4
Returns a transformation matrix that transforms points onto the plane specified with planeNormal and planePoint.
makePlaneReflection(Vector3 planeNormal, Vector3 planePoint) Matrix4
Returns a transformation matrix that transforms points by reflecting them through the plane specified with planeNormal and planePoint.
makeViewMatrix(Vector3 cameraPosition, Vector3 cameraFocusPosition, Vector3 upDirection) Matrix4
Constructs a new OpenGL view matrix.
mix(double min, double max, double a) double
Interpolate between min and max with the amount of a using a linear interpolation. The computation is equivalent to the GLSL function mix.
pickRay(Matrix4 cameraMatrix, num viewportX, num viewportWidth, num viewportY, num viewportHeight, num pickX, num pickY, Vector3 rayNear, Vector3 rayFar) bool
On success, rayNear and rayFar are the points where the screen space pickX, pickY intersect with the near and far planes respectively.
radians(double degrees) double
Convert degrees to radians.
relativeError(dynamic calculated, dynamic correct) double
Returns relative error between calculated and correct. The type of calculated and correct must match and can be any vector, matrix, or quaternion.
setFrustumMatrix(Matrix4 perspectiveMatrix, double left, double right, double bottom, double top, double near, double far) → void
Constructs an OpenGL perspective projection matrix in perspectiveMatrix.
setInfiniteMatrix(Matrix4 infiniteMatrix, double fovYRadians, double aspectRatio, double zNear) → void
Constructs an OpenGL infinite projection matrix in infiniteMatrix. fovYRadians specifies the field of view angle, in radians, in the y direction. aspectRatio specifies the aspect ratio that determines the field of view in the x direction. The aspect ratio of x (width) to y (height). zNear specifies the distance from the viewer to the near plane (always positive).
setModelMatrix(Matrix4 modelMatrix, Vector3 forwardDirection, Vector3 upDirection, double tx, double ty, double tz) → void
Constructs an OpenGL model matrix in modelMatrix. Model transformation is the inverse of the view transformation. Model transformation is also known as "camera" transformation. Model matrix is commonly used to compute a object location/orientation into the full model-view stack.
setOrthographicMatrix(Matrix4 orthographicMatrix, double left, double right, double bottom, double top, double near, double far) → void
Constructs an OpenGL orthographic projection matrix in orthographicMatrix.
setPerspectiveMatrix(Matrix4 perspectiveMatrix, double fovYRadians, double aspectRatio, double zNear, double zFar) → void
Constructs an OpenGL perspective projection matrix in perspectiveMatrix.
setRotationMatrix(Matrix4 rotationMatrix, Vector3 forwardDirection, Vector3 upDirection) → void
Constructs a rotation matrix in rotationMatrix.
setViewMatrix(Matrix4 viewMatrix, Vector3 cameraPosition, Vector3 cameraFocusPosition, Vector3 upDirection) → void
Constructs an OpenGL view matrix in viewMatrix. View transformation is the inverse of the model transformation. View matrix is commonly used to compute the camera location/orientation into the full model-view stack.
smoothStep(double edge0, double edge1, double amount) double
Do a smooth step (hermite interpolation) interpolation with edge0 and edge1 by amount. The computation is equivalent to the GLSL function smoothstep.
unproject(Matrix4 cameraMatrix, num viewportX, num viewportWidth, num viewportY, num viewportHeight, num pickX, num pickY, num pickZ, Vector3 pickWorld) bool
On success, Sets pickWorld to be the world space position of the screen space pickX, pickY, and pickZ.

Typedefs

ComponentSetFactory = ComponentSet Function()
KeyHandlerCallback = bool Function(Set<LogicalKeyboardKey>)
The signature for a key handle function
ShapeBuilder = Shape Function(Vector2 size)
A function that creates a shape based on a size represented by a Vector2