Your First Flutter Flame Game

Mar 6 2024 · Dart 3, Flutter 3.10.1, Android Studio 2021.3.1 or higher, Visual Studo Code 1.7.4 or higher

Part 1: Getting Started With Flame

05. Enable Debug Mode in Components

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 04. Add Components to Meteormania Next episode: 06. Challenge: Add Saucer Component

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

MeteormaniaGame

To manage the logic of the game you’ll be using GameManager which is a class that handles the logic of the game. You can think of it as the state of the game. It holds information about the level being played, points scored, enemy quantity and health points.

GameManager manager = GameManager();
void addEnemies() {
}
final meteorites = List.generate(manager.level, (i) {
})
final isBigMeteorite = Random().nextBool();
if (isBigMeteorite) {
}
final spriteSize = Meteorite.bigSize.toSize();
final (meteoriteX, meteoriteY) = randomPosition(
  spriteSize.width,
  spriteSize.height,
  Spaceship.spaceshipSize.toSize(),
);
return Meteorite.big()
  ..anchor = Anchor.center
  ..position = Vector2(meteoriteX, meteoriteY);
final spriteSize = Meteorite.smallSize.toSize();
final (meteoriteX, meteoriteY) = randomPosition(
  spriteSize.width,
  spriteSize.height,
  Spaceship.spaceshipSize.toSize(),
);
return Meteorite.small()
  ..anchor = Anchor.center
  ..position = Vector2(meteoriteX, meteoriteY);

_world.addAll(meteorites);
addEnemies();

Override debugMode in MeteormaniaGame

Open meteormania_game.dart and enable debugging mode by overriding the variable debugMode in MeteormaniaGame.

@override
bool get debugMode => true;