I am pretty new to the flame game engine built on top of flutter but I am wanting to render a parallax image for my background but when I try to render it in my main game class it won't show up?
class BackGround extends AnimationComponent {
Rect backgroundRect;
ParallaxComponent _parallaxComponent;
BackGround() : super.empty() {
backgroundRect = Rect.fromLTWH(
100,
100,
100,
100,
);
}
void render(Canvas c) {
_parallaxComponent = ParallaxComponent([
ParallaxImage('Layer_0010_1.png'),
ParallaxImage('Layer_0009_2.png'),
ParallaxImage('Layer_0008_3.png'),
ParallaxImage('Layer_0006_4.png'),
ParallaxImage('Layer_0005_5.png'),
ParallaxImage('Layer_0003_6.png'),
ParallaxImage('Layer_0002_7.png'),
ParallaxImage('Layer_0001_8.png'),
ParallaxImage('Layer_0000_9.png'),
], baseSpeed: Offset(100, 0), layerDelta: Offset(20, 0));
_parallaxComponent.render(c);
}
}
Here is what my main game class looks like.
class MainGame extends BaseGame with TapDetector, HasWidgetsOverlay {
BackGround backback;
Size screenSize;
MainGame(this.storage) {
initialize();
}
void initialize() async {
// resize(await Flame.util.initialDimensions());
backback = BackGround();
}
void render(Canvas c) {
backback.render(c);
}
}