Skip to content

Commit

Permalink
docs: Fix exception thrown in ember quest tutorial (#3228)
Browse files Browse the repository at this point in the history
Ember quest's run button was throwing an `unimplemented error`. This was
happening was `EmberQuestGame.loadGameSegments`'s pattern matching was
failing to match the block types. It seems for patterns involving
`Type`, the correct way is to use `const (Foo)`. See second example
[here](https://dart.dev/tools/linter-rules/type_literal_in_constant_pattern#details).
  • Loading branch information
ufrshubham authored Jul 21, 2024
1 parent df9be25 commit 83352ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions doc/tutorials/platformer/app/lib/ember_quest.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ class EmberQuestGame extends FlameGame
void loadGameSegments(int segmentIndex, double xPositionOffset) {
for (final block in segments[segmentIndex]) {
final component = switch (block.blockType) {
GroundBlock _ => GroundBlock(
const (GroundBlock) => GroundBlock(
gridPosition: block.gridPosition,
xOffset: xPositionOffset,
),
PlatformBlock _ => PlatformBlock(
const (PlatformBlock) => PlatformBlock(
gridPosition: block.gridPosition,
xOffset: xPositionOffset,
),
Star _ => Star(
const (Star) => Star(
gridPosition: block.gridPosition,
xOffset: xPositionOffset,
),
WaterEnemy _ => WaterEnemy(
const (WaterEnemy) => WaterEnemy(
gridPosition: block.gridPosition,
xOffset: xPositionOffset,
),
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorials/platformer/step_6.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class HeartHealthComponent extends SpriteGroupComponent<HeartState>
```

The `HeartHealthComponent` is just a [SpriteGroupComponent](../../flame/components.md#spritegroup)
The `HeartHealthComponent` is just a [SpriteGroupComponent](../../flame/components.md#spritegroupcomponent)
that uses the heart images that were created early on. The unique thing that is being done, is when
the component is created, it requires a `heartNumber`, so in the `update` method, we check to see if
the `game.health` is less than the `heartNumber` and if so, change the state of the component to
Expand Down

0 comments on commit 83352ac

Please sign in to comment.