SimpleGameManager class

Inheritance

Constructors

SimpleGameManager({FlameWidget? onGenerateRoute(RouteSettings settings)?, FlameWidget? home, String? initialRoute})
Creates a basic game manager, should be enough for most use cases Home or initialroute must be set if routing is used, you must set onGenerateRoute

Properties

assets ↔ AssetsCache
The cache of all (non-image) assets loaded into the game. This defaults to the global Flame.assets cache, but you can replace this with another instance if needed.
getter/setter pairinherited
buildContext BuildContext?
Currently attached build context. Can be null if not attached.
no setterinherited
canvasSize → Vector2
no setterinherited
currentDialog FlameWidget?
getter/setter pairinherited
currentDialogCompleter Completer?
getter/setter pairinherited
currentScreen FlameWidget
getter/setter pairinherited
dialogRoute FlameRoute?
getter/setter pairinherited
gameStateListeners List<VoidCallback>
finalinherited
gestureDetectors → GestureDetectorBuilder
Used internally by various mixins that need to use gesture detection functionality in Flutter.
latefinalinherited
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
images ↔ Images
The cache of all images loaded into the game. This defaults to the global Flame.images cache, but you can replace it with a new cache instance if needed.
getter/setter pairinherited
isAttached bool
Whether the game widget was attached to the Flutter tree.
no setterinherited
lastDragPosition ↔ Vector2
getter/setter pair
lastScale double
getter/setter pair
lastScalePosition ↔ Vector2
getter/setter pair
mouseCursor 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.
getter/setter pairinherited
mouseDetector ↔ (void Function(PointerHoverEvent event)?)
Set by the PointerMoveDispatcher to receive mouse events from the game widget.
getter/setter pairinherited
overlays → OverlayManager
A property that stores an OverlayManager
latefinalinherited
paused bool
Returns is the engine if currently paused or running
getter/setter pairinherited
renderBox → GameRenderBox
Just a reference back to the render box that is kept up to date by the engine.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size → Vector2
Current game viewport size, updated every resize via the onGameResize method hook.
no setterinherited
stack List<FlameRoute>
getter/setter pairinherited

Methods

addGameStateListener(VoidCallback callback) → void
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
build({BuildContext? testContext}) → void
override
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
detach() → void
Marks game as no longer attached to any Flutter widget tree.
inherited
finalizeRemoval() → void
inherited
getCurrentRoute() FlameRoute
inherited
handleScaleEnd(ScaleEndDetails details) → void
inherited
handleScaleStart(ScaleStartDetails details) → void
inherited
handleScaleUpdate(ScaleUpdateDetails details) → void
inherited
handleTapDown(TapDownDetails details) → void
inherited
handleTapUp(TapUpDetails details) → void
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
load() FutureOr<void>
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
mount() → void
inherited
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 overridden 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 overridden to add logic that requires the game not be on the flutter widget tree anymore.
inherited
onDispose() → void
Called when the GameWidget is disposed by Flutter.
inherited
onGameResize(Vector2 size) → void
This is the resize hook; every time the game widget is resized, this hook is called.
onGenerateRoute(RouteSettings settings) FlameWidget?
Implement this function to use the navigator, ignore it to use a custom implementation inside the home widget
override
onLoad() Future<void>
Method to perform late initialization of the Game class.
onMount() → void
inherited
onRemove() → void
Called when the game is about to be removed from the Flutter widget tree, but before it is actually removed. See the docs for an example on how to do cleanups to avoid memory leaks.
inherited
onScaleEnd(dynamic event) → void
onScaleStart(dynamic event) → void
onScaleUpdate(dynamic event) → void
onTap() → void
inherited
onTapCancel() → void
inherited
onTapDown(dynamic event) → void
onTapUp(dynamic event) → void
pauseEngine() → void
Pauses the engine game loop execution.
inherited
pop({dynamic result}) → void
inherited
popAndPushNamed(String route, {dynamic arguments}) Future
inherited
popUntil(bool check(FlameRoute route), {dynamic result}) → void
inherited
push(FlameWidget screen, {RouteSettings? routeSettings}) Future
inherited
pushNamed(String route, {dynamic arguments}) Future
inherited
refreshWidget({bool isInternalRefresh = true}) → void
When a Game is attached to a GameWidget, this method will force that widget to be rebuilt. This can be used when updating any property which is implemented within the Flutter tree.
inherited
removeGameStateListener(VoidCallback callback) → void
inherited
render(Canvas canvas) → void
This should render the game.
resumeEngine() → void
Resumes the engine game loop execution.
inherited
showDialog(FlameWidget dialog) Future
inherited
stepEngine({double stepTime = 1 / 60}) → void
Steps the engine game loop by one frame. Works only if the engine is in paused state. By default step time is assumed to be 1/60th of a second.
inherited
toBeLoaded() FutureOr<void>
To be used for tests that needs to evaluate the game after it has been loaded by the game widget.
inherited
toString() String
A string representation of this object.
inherited
update(double deltaTime) → void
This should update the state of the game.

Operators

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