BonfireGame class
Is a customGame where all magic of the Bonfire happen.
- Inheritance
- Implemented types
- Available extensions
Constructors
-
BonfireGame.new({required BuildContext context, required MapGame map, JoystickController? joystickController, Player? player, GameInterface? interface, List<
Enemy> ? enemies, List<GameDecoration> ? decorations, List<GameComponent> ? components, GameBackground? background, bool constructionMode = false, bool showCollisionArea = false, GameController? gameController, Color? constructionModeColor, Color? collisionAreaColor, Color? lightingColorGame, bool showFPS = false, ValueChanged<BonfireGame> ? onReady, TapInGame? onTapDown, TapInGame? onTapUp, GameColorFilter? colorFilter, CameraConfig? cameraConfig})
Properties
- assets → AssetsCache
-
finalinherited
- background → GameBackground?
-
Background of the game. This can be a color or custom component
final
- buildContext → BuildContext?
-
Currently attached build context. Can be null if not attached.
no setterinherited
- camera ↔ Camera
-
getter/setter pairinherited
- children → ComponentSet
-
latefinalinherited
- collisionAreaColor → Color?
-
Color of the collision area when
showCollisionArea
is truefinal - colorFilter → ColorFilterInterface?
-
no setteroverride
- constructionMode → bool
-
Used to show grid in the map and facilitate the construction and testing of the map
final
- constructionModeColor → Color?
-
Color grid when
constructionMode
is truefinal - context → BuildContext
-
Context used to access all Flutter power in your game.
final
- 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
- gameController → GameController?
-
Used to extensively control game elements
final
- 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 setterinherited
- images → Images
-
finalinherited
- interface → GameInterface?
-
The way you can draw things like life bars, stamina and settings. In another words, anything that you may add to the interface to the game.
final
- 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
- joystick → JoystickController?
-
no setteroverride
- lighting → LightingInterface?
-
no setteroverride
- lightingColorGame → Color?
-
Used to configure lighting in the game
final
- map → MapGame
-
Represents a map (or world) where the game occurs.
final
-
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 -
onReady
↔ ValueChanged<
BonfireGame> ? -
getter/setter pair
- onTapDown → TapInGame?
-
final
- onTapUp → TapInGame?
-
final
- 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
- player → Player?
-
Represents the character controlled by the user in the game. Instances of this class has actions and movements ready to be used and configured.
final
- 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
- showCollisionArea → bool
-
Used to draw area collision in objects.
final
- showFPS → bool
-
Used to show in the interface the FPS.
final
- 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
override
-
addAll(
Iterable< Component> components) → Future<void> -
Adds multiple children.
override
-
addJoystickObserver(
GameComponent target, {bool cleanObservers = false, bool moveCameraToTarget = false}) → void -
Use this method to change default observer of the Joystick events.
override
-
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
-
attackables(
) → Iterable< Attackable> -
override
-
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
-
collisions(
) → Iterable< ObjectCollision> -
override
-
componentsByType<
T> () → Iterable< T> -
override
-
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 -
decorations(
) → Iterable< GameDecoration> -
override
-
detach(
) → void -
Marks game as no longer attached to any Flutter widget tree.
inherited
-
enemies(
) → Iterable< Enemy> -
override
-
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 -
getValueGenerator(
Duration duration, {double begin = 0.0, double end = 1.0, Curve curve = Curves.decelerate, VoidCallback? onFinish, ValueChanged< double> ? onChange}) → ValueGeneratorComponent -
override
-
isVisibleInCamera(
GameComponent c) → bool -
override
-
lifecycleStateChange(
AppLifecycleState state) → void -
This is the lifecycle state change hook; every time the game is resumed,
paused or suspended, this is called.
inherited
-
lightVisible(
) → Iterable< Lighting> -
override
-
livingEnemies(
) → Iterable< Enemy> -
override
-
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
-
onKeyEvent(
RawKeyEvent event, Set< LogicalKeyboardKey> keysPressed) → KeyEventResult -
onLoad(
) → Future< void> ? -
Whenever onLoad returns something, the parent will wait for the Future
to be resolved before adding it.
If
null
is returned, the class is added right away. -
onMount(
) → void - Called after the component has successfully run onLoad and before the component is added to its new parent.
-
onPointerCancel(
PointerCancelEvent event) → void -
inherited
-
onPointerDown(
PointerDownEvent event) → void -
override
-
onPointerHover(
PointerHoverEvent event) → void -
inherited
-
onPointerMove(
PointerMoveEvent event) → void -
inherited
-
onPointerSignal(
PointerSignalEvent event) → void -
inherited
-
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.
inherited
-
renderComponent(
Canvas canvas, Component comp) → void -
This renders a single component obeying BaseGame rules.
inherited
-
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
-
screenPositionToWorld(
Offset position) → Offset -
override
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
double t) → void -
This implementation of update updates every component in the list.
override
-
updateOrderPriority(
) → void -
reorder components by priority
inherited
-
visibleAttackables(
) → Iterable< Attackable> -
override
-
visibleCollisions(
) → Iterable< ObjectCollision> -
override
-
visibleComponents(
) → Iterable< GameComponent> -
override
-
visibleComponentsByType<
T> () → Iterable< T> -
override
-
visibleDecorations(
) → Iterable< GameDecoration> -
override
-
visibleEnemies(
) → Iterable< Enemy> -
override
-
visibleSensors(
) → Iterable< Sensor> -
override
-
worldPositionToScreen(
Offset position) → Offset -
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- INTERVAL_UPDATE_CACHE → const int
- INTERVAL_UPDATE_COLLISIONS → const int
- INTERVAL_UPDATE_ORDER → const int