flame_forge2d 0.6.3-rc4 copy "flame_forge2d: ^0.6.3-rc4" to clipboard
flame_forge2d: ^0.6.3-rc4 copied to clipboard

outdated

Forge2D (Box2D) support for the Flame game engine. This uses the forge2d package and provides wrappers and components to be used inside Flame.

example/lib/main.dart

import 'package:dashbook/dashbook.dart';
import 'package:flame/game.dart';
import 'package:flame/extensions.dart';
import 'package:flutter/material.dart';
import 'package:forge2d_samples/draggable_sample.dart';
import 'package:forge2d_samples/mouse_joint_sample.dart';
import 'package:forge2d_samples/tapable_sample.dart';

import './sprite_body_sample.dart';
import './contact_callbacks_sample.dart';
import './domino_sample.dart';
import 'blob_sample.dart';
import 'circle_stress_sample.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final dashbook = Dashbook();

  Vector2 ctxSize(DashbookContext ctx) => ctx.constraints.biggest.toVector2();

  dashbook.storiesOf('Flame with Forge2D').decorator(TopDecorator())
    ..add(
      'Blob sample',
      (DashbookContext ctx) => GameWidget(game: BlobSample(ctxSize(ctx))),
    )
    ..add(
      'Domino sample',
      (DashbookContext ctx) => GameWidget(game: DominoSample(ctxSize(ctx))),
    )
    ..add(
      'Contact Callbacks',
      (DashbookContext ctx) =>
          GameWidget(game: ContactCallbacksSample(ctxSize(ctx))),
    )
    ..add(
      'Circle stress sample',
      (DashbookContext ctx) =>
          GameWidget(game: CircleStressSample(ctxSize(ctx))),
    )
    ..add(
      'Sprite Bodies',
      (DashbookContext ctx) => GameWidget(game: SpriteBodySample(ctxSize(ctx))),
    )
    ..add(
      'Tapable Body',
      (DashbookContext ctx) => GameWidget(game: TapableSample(ctxSize(ctx))),
    )
    ..add(
      'Draggable Body',
      (DashbookContext ctx) => GameWidget(game: DraggableSample(ctxSize(ctx))),
    )
    ..add(
      'Mouse Joint',
      (DashbookContext ctx) => GameWidget(game: MouseJointSample(ctxSize(ctx))),
    );
  runApp(dashbook);
}

class TopDecorator extends Decorator {
  @override
  Widget decorate(Widget child) {
    return Align(
      child: child,
      alignment: Alignment.topCenter,
    );
  }
}
65
likes
0
pub points
94%
popularity

Publisher

verified publisherflame-engine.org

Forge2D (Box2D) support for the Flame game engine. This uses the forge2d package and provides wrappers and components to be used inside Flame.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flame, flutter, forge2d

More

Packages that depend on flame_forge2d