BaseGame class abstract
CustomBaseGame created to use Listener
to capture touch screen gestures.
Apply zoom in canvas.
Reorder components per time frame.
- Inheritance
- Mixed-in types
- Implementers
- Available extensions
Constructors
Properties
- assets → AssetsCache
-
finalinherited
- buildContext → BuildContext?
-
Currently attached build context. Can be null if not attached.
no setterinherited
- camera ↔ Camera
-
getter/setter pair
- children → ComponentSet
-
latefinalinherited
- debugColor ↔ Color
-
The color that the debug output should be rendered with.
getter/setter pairinherited
- debugCoordinatesPrecision → int?
-
How many decimal digits to print when displaying coordinates in the
debug mode. Setting this to null will suppress all coordinates from
the output.
no setterinherited
- debugMode ↔ bool
-
Returns whether this Component is in debug mode or not.
When a child is added to the Component it gets the same debugMode as
its parent has when it is prepared.
getter/setter pairinherited
- debugPaint → Paint
-
The debugColor represented as a Paint object.
no setterinherited
- debugTextPaint → TextPaint
-
Returns a TextPaint object with the debugColor set as color for the
text.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasLayout → bool
-
Indicates if this game instance is connected to a GameWidget that is live
in the flutter widget tree.
Once this is true, the game is ready to have its size used or in the case
of a FlameGame, to receive components.
no setterinherited
- highestPriority → int
-
Get of the _highestPriority
no setter
- images → Images
-
finalinherited
- isAttached → bool
-
Whether the game widget was attached to the Flutter tree.
no setterinherited
- isHud ↔ bool
-
Whether this component is a HUD (Heads-up display) object or not.
getter/setter pairinherited
- isLoaded ↔ bool
-
Whether this component is done loading through
onLoad
.getter/setter pairinherited - isMounted ↔ bool
-
Whether this component is currently added to a component tree.
getter/setter pairinherited
- isPrepared ↔ bool
-
Whether this component has been prepared and is ready to be added to the
game loop.
getter/setter pairinherited
-
mouseCursor
→ ValueNotifier<
MouseCursor?> -
Used to change the mouse cursor of the GameWidget running this game.
Setting the value to null will make the GameWidget defer the choice
of the cursor to the closest region available on the tree.
finalinherited
- nextParent ↔ Component?
-
If the component should be added to another parent once it has been
removed from its current parent.
getter/setter pairinherited
-
onLoadCache
↔ Future<
void> ? -
Since
onLoad
only should run once throughout a the lifetime of the implementing class, it is cached so that it can be reused when the parent component/game/widget changes.getter/setter pairinherited - overlays → ActiveOverlaysNotifier
-
A property that stores an
ActiveOverlaysNotifier
finalinherited - parent → Component?
-
Get the current parent of the component, if there is one, otherwise null.
no setterinherited
- paused ↔ bool
-
Returns is the engine if currently paused or running
getter/setter pairinherited
- pauseEngineFn ↔ VoidCallback?
-
getter/setter pairinherited
- priority → int
-
Render priority of this component. This allows you to control the order in
which your components are rendered.
no setterinherited
- projector ↔ Projector
-
This is the projector used by non-isHUD components.
This can be overriden on your
Game
implementation.getter/setter pairinherited - resumeEngineFn ↔ VoidCallback?
-
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shouldRemove ↔ bool
-
Whether this component should be removed or not.
getter/setter pairinherited
- size → Vector2
-
Current game viewport size, updated every resize via the
onGameResize
method hook.no setterinherited - viewportProjector ↔ Projector
-
This is the projector used by isHUD components.
This can be overriden on your
Game
implementation.getter/setter pairinherited
Methods
-
add(
Component component) → Future< void> -
Prepares and registers a component to be added on the next game tick
inherited
-
addAll(
Iterable< Component> components) → Future<void> -
Adds multiple children.
inherited
-
ancestors(
) → List< Component> -
A list containing the current parent and its parent, and so on, until it
reaches a component without a parent.
inherited
-
assertHasLayout(
) → void -
inherited
-
attach(
PipelineOwner owner, GameRenderBox gameRenderBox) → void -
Marks game as attached to any Flutter widget tree.
inherited
-
backgroundColor(
) → Color -
Returns the game background color.
By default it will return a black color.
It cannot be changed at runtime, because the game widget does not get
rebuild when this value changes.
inherited
-
changeParent(
Component component) → void -
Changes the current parent for another parent and prepares the tree under
the new root.
inherited
-
changePriorityWithoutResorting(
int priority) → void -
Usually this is not something that the user would want to call since the
component list isn't re-ordered when it is called.
See FlameGame.changePriority instead.
inherited
-
contains(
Component c) → bool -
Whether the children list contains the given component.
inherited
-
containsPoint(
Vector2 point) → bool -
Called to check whether the point is to be counted as within the component
It needs to be overridden to have any effect, like it is in
PositionComponent.
inherited
-
convertGlobalToLocalCoordinate(
Vector2 point) → Vector2 -
Converts a global coordinate (i.e. w.r.t. the app itself) to a local
coordinate (i.e. w.r.t. he game widget).
If the widget occupies the whole app ("full screen" games), or is not
attached to Flutter, this operation is the identity.
inherited
-
convertLocalToGlobalCoordinate(
Vector2 point) → Vector2 -
Converts a local coordinate (i.e. w.r.t. the game widget) to a global
coordinate (i.e. w.r.t. the app itself).
If the widget occupies the whole app ("full screen" games), or is not
attached to Flutter, this operation is the identity.
inherited
-
createComponentSet(
) → ComponentSet -
This method sets up the
OrderedSet
instance used by this component to handle its children, This is set up before any lifecycle methods happen.inherited -
detach(
) → void -
Marks game as no longer attached to any Flutter widget tree.
inherited
-
eventPosition(
PositionInfo info) → Vector2 -
inherited
-
findParent<
T extends Component> () → T? -
Finds the closest parent further up the hierarchy that satisfies type=T,
or null if none is found.
inherited
-
fps(
[int average = 1]) → double -
Returns the FPS based on the frame times from
onTimingsCallback
.inherited -
lifecycleStateChange(
AppLifecycleState state) → void -
This is the lifecycle state change hook; every time the game is resumed,
paused or suspended, this is called.
inherited
-
loadSprite(
String path, {Vector2? srcSize, Vector2? srcPosition}) → Future< Sprite> -
Utility method to load and cache the image for a sprite based on its
options.
inherited
-
loadSpriteAnimation(
String path, SpriteAnimationData data) → Future< SpriteAnimation> -
Utility method to load and cache the image for a sprite animation based on
its options.
inherited
-
loadSpriteBatch(
String path, {Color defaultColor = const Color(0x00000000), BlendMode defaultBlendMode = BlendMode.srcOver, RSTransform? defaultTransform}) → Future< SpriteBatch> -
Available on Game, provided by the SpriteBatchExtension extension
Utility method to load and cache the image for a SpriteBatch based on its options -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onAttach(
) → void -
Called when the game has been attached. This can be overriden
to add logic that requires the game to already be attached
to the widget tree.
inherited
-
onDetach(
) → void -
Called after the game has left the widget tree.
This can be overriden to add logic that requires the game
not be on the flutter widget tree anymore.
inherited
-
onGameResize(
Vector2 size) → void -
It receives the new game size.
Executed right after the component is attached to a game and right before
onLoad is called.
override
-
onLoad(
) → Future< void> ? -
Whenever
onLoad
returns something, the parent will wait for the Future to be resolved before adding it. Ifnull
is returned, the class is added right away.inherited -
onMount(
) → void -
Called after the component has successfully run
onLoad
and before the component is added to its new parent.inherited -
onPointerCancel(
PointerCancelEvent event) → void -
override
-
onPointerDown(
PointerDownEvent event) → void -
override
-
onPointerHover(
PointerHoverEvent event) → void -
override
-
onPointerMove(
PointerMoveEvent event) → void -
override
-
onPointerSignal(
PointerSignalEvent event) → void -
override
-
onPointerUp(
PointerUpEvent event) → void -
override
-
onRemove(
) → void -
Called right before the component is removed from the game.
inherited
-
onTimingsCallback(
List< FrameTiming> timings) → void -
Use for calculating the FPS.
inherited
-
pauseEngine(
) → void -
Pauses the engine game loop execution.
inherited
-
prepare(
Component parent) → void -
Prepares the Component to be added to a
parent
, and if there is an ancestor that is aFlameGame
that game will do necessary preparations for this component. If there are no parents that are aGame
false will be returned and this will run again once an ancestor or the component itself is added to aGame
.inherited -
propagateToChildren<
T extends Component> (bool handler(T)) → bool -
This method first calls the passed handler on the leaves in the tree,
the children without any children of their own.
Then it continues through all other children. The propagation continues
until the handler returns false, which means "do not continue", or when
the handler has been called with all children.
inherited
-
reAddChildren(
) → Future< void> -
The children are added again to the component set so that prepare,
onLoad
andonMount
runs again. Used when a parent is changed further up the tree.inherited -
remove(
Component c) → void -
Removes a component from the component tree, calling onRemove for it and
its children.
inherited
-
removeAll(
Iterable< Component> cs) → void -
Removes all the children in the list and calls onRemove for all of them
and their children.
inherited
-
removeFromParent(
) → void -
Remove the component from its parent in the next tick.
inherited
-
render(
Canvas canvas) → void -
This implementation of render basically calls renderComponent for every component, making sure the canvas is reset for each one.
override
-
renderComponent(
Canvas canvas, Component comp) → void - This renders a single component obeying BaseGame rules.
-
renderDebugMode(
Canvas canvas) → void -
inherited
-
renderTree(
Canvas canvas) → void -
inherited
-
reorderChildren(
) → void -
Call this if any of this component's children priorities have changed
at runtime.
inherited
-
resumeEngine(
) → void -
Resumes the engine game loop execution.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
double dt) → void -
This implementation of update updates every component in the list.
override
-
updateOrderPriority(
) → void - reorder components by priority
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited