VeryGoodOpenSource / very_good_flame_game

A Very Good Flutter Starter Flame Game created by the Very Good Ventures Team 🦄
https://brickhub.dev/bricks/very_good_flame_game
MIT License
85 stars 11 forks source link

fix: SpriteAnimation errors listed in Dart Analysis and app won't run #103

Closed Stef-GMS closed 1 year ago

Stef-GMS commented 1 year ago

Description When using the VGV CLI to create a Flame game there are 13 errors listed in Dart Analysis and the template app won't run.

Steps To Reproduce

  1. From terminal run: very_good create flutter_app very_good_flutter_app --desc "A Flutter app built using Very Good Ventures Very Good CLI"
  2. Open project in IntelliJ
  3. Look at Dart Analysis tab
  4. See 13 errors - most of which are pertaining to Sprite Animation.
  5. There are also 6 hints, including that HasTappables and Camera have been deprecated (I know Camera deprecation is in the last week).

Expected Behavior No Dart Analysis errors to be listed.

Screenshots

image

Additional Context Macbook Pro M1 macOS 13.3.1 IntelliJ IDEA 2022.3.3 (Community Edition) Flutter 3.10.0 (tried rolling back. Still gave errors) Dart Dart 3.0.2 (tried rolling back. Still gave errors) pubspec.yaml was not updated so entries remained as shown below. Even updating them didn't solve issue. I also tried rolling back. Still gave errors)

image
Shortyyy commented 1 year ago

class Unicorn extends PositionedEntity with HasGameRef {
  Unicorn({
    required super.position,
  }) : super(
          anchor: Anchor.center,
          size: Vector2.all(32),
          behaviors: [
            TappingBehavior(),
          ],
        );

  late SpriteAnimationComponent? _animation;

  @visibleForTesting
  Unicorn.test({
    required super.position,
    super.behaviors,
  }) : super(size: Vector2.all(32));

  @visibleForTesting
  SpriteAnimationComponent get animation => _animation!;

  @override
  Future<void> onLoad() async {
    _animation = SpriteAnimationComponent(
      animation: await gameRef.loadSpriteAnimation(
        Assets.images.unicornAnimation.path,
        SpriteAnimationData.sequenced(
          amount: 16,
          stepTime: 0.1,
          textureSize: Vector2.all(32),
          loop: false,
        ),
      ),
      size: size,
    );

    await add(animation);
  }

  /// Plays the animation.
  void playAnimation() => animation.animationTicker!.reset();

  /// Returns whether the animation is playing or not.
  bool isAnimationPlaying() => !animation.animationTicker!.isLastFrame;
}
renancaraujo commented 1 year ago

Tracking on https://github.com/VeryGoodOpenSource/very_good_cli/issues/770