So I’m trying to learn Flame and there is this concept of adding components to the World
and adding components directly to FlameGame
. I kind of understood that the world
works with the camera
somehow. But the topics are still not clear to me. So this is my first step towards understanding this. I’ve read the docs but didn’t really understand much. I would really appreciate if someone can take the time to explain this concept of world, camera and how adding children to the world
differs from adding them to the FlameGame
. Thank you.
import 'dart:async';
import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'components/components.dart';
import 'config.dart';
class BrickBreaker extends FlameGame {
BrickBreaker()
: super(
camera: CameraComponent.withFixedResolution(
width: gameWidth,
height: gameHeight,
),
);
double get width => size.x;
double get height => size.y;
@override
FutureOr<void> onLoad() async {
super.onLoad();
camera.viewfinder.anchor = Anchor.topLeft;
// adding to world, but why not add directly to the current component?
// add(PlayArea())
world.add(PlayArea());
}
}