Plugin for integrating composition rendering into the Flame game engine.

Overview

Pub Version Pub Version

Usage FlamePluginComponent

A simple usage example:

import 'package:composition_rendering/scene.dart';
import 'package:flame/flame.dart';
import 'package:flame/game.dart';
import 'package:flame_composition_rendering/flame_plugin.dart';
import 'package:flutter/widgets.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(
    GameWidget(
      game: ExampleLauncher(),
    ),
  );
}

class ExampleLauncher extends BaseGame {
  final FlamePluginComponent plugin = FlamePluginComponent();

  ExampleLauncher() {
    plugin.scene = GameScene();
  }

  @override
  Future<void> onLoad() async {
    await Flame.images.loadAll([
      'bg.jpg',
    ]);
    await add(plugin);
  }
}

class GameScene extends Scene {
  @override
  void init() {
    // your play scene
  }
}

Usage SpriteBatchComponent

Alternative SpriteBatch for Flame. Rendering three sprites in one call Canvas.drawRawAtlas

import 'package:flame/components.dart';
import 'package:flame/flame.dart';
import 'package:flame/game.dart';
import 'package:flame_composition_rendering/flame_composition_rendering.dart';
import 'package:flutter/material.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  Flame.device.fullScreen();
  Flame.device.setLandscape();

  runApp(
    GameWidget(
      game: ExampleLauncher(),
    ),
  );
}

class ExampleLauncher extends BaseGame {
  @override
  Future<void> onLoad() async {
    await Flame.images.loadAll(['crab.png']);
    await add(SpriteBatchComponent());
  }

  @override
  Color backgroundColor() => const Color(0xFFFFFFFF);
}

class SpriteBatchComponent extends FlameBatchComponent {
  late final image;
  late final sprite;

  @override
  Future<void>? onLoad() {
    image = Flame.images.fromCache('crab.png');
    sprite = Sprite(image);
  }

  @override
  void beginBatch() {
    drawSprite(sprite, x: 100, y: 200);
    drawSprite(sprite, x: 200, y: 200);
    drawSprite(sprite, x: 300, y: 200);
    drawSpriteFromComponents(sprite, x: 400, y: 100, rotation: 0.4, scale: 0.6);
  }
}

Support

You can support the development of libraries for creating multiplatform games in Flutter:

Patreon

You might also like...

Team Dexters(yeah, I came out with a name .) Flame Game Jam repo

flame_game_jam_dexters Credits Image assets Flame Images: https://github.com/flame-engine/flame Ghost: https://master-blazter.itch.io/ghostspritepack

Nov 2, 2021

A game powered by Flutter and Flame

A game powered by Flutter and Flame

Flutters About Flutters is a demo game powered by Flutter and Flame. I wrote it to test out its performance and gaming capabilities and decided to ope

Jan 3, 2023

Td - FreeDefense Game with Flutter and Flame

Td - FreeDefense Game with Flutter and Flame

td from https://github.com/cloudseasail/free_defense Some change , added Bloc fo

Jun 24, 2022

Little Super Mario game developed with Flame in Flutter

First Game Generated by the Very Good CLI 🤖 A Very Good Project created by Very Good CLI. Getting Started 🚀 This project contains 3 flavors: develop

Aug 10, 2022

A Dwarf game made with Dart, Flutter and Flame

Dwart Generated by the Very Good CLI 🤖 Dwart game Getting Started 🚀 This project contains 3 flavors: development staging production To run the desir

Jun 11, 2022

A minimalist Flutter game engine

A minimalist Flutter game engine

A minimalistic Flutter game engine. English | 简体中文 | Polski | Русский About 1.0.0 Our goal is to release v1 soon. We are periodically launching RCs (r

Jan 8, 2023

A Flutter RPG Game Engine.

A Flutter RPG Game Engine.

DevilF 游戏引擎 A Flutter RPG Game Engine. 一款使用Flutter开发的RPG游戏引擎。 引擎介绍 (Devil Fighter) 自从有了Flutter,轻松实现了三端跨平台,并且不增加包体积,就能拥有一套Native游戏引擎,为APP游戏化提供了更多可能性。 开

Dec 21, 2022

A minimalist Flutter game engine

A minimalist Flutter game engine

A minimalistic Flutter game engine. English | 简体中文 | Polski | Русский | Español About 1.0.0 Our goal is to release v1 soon. We are periodically launch

Dec 31, 2022

A Widget-based Game Engine For Flutter

illume A Widget-based Game Engine for Flutter Illume is a simple Flutter game engine which uses widgets to create game objects instead of sprites in n

Nov 9, 2022
Owner
Stanislav
migrating to Dart
Stanislav
Watermelon is a game developed using Flutter+Flame+Forge2D. 合成大瓜是使用Flutter+Flame+Forge2D开发的一个开源小游戏(Flutter版合成大西瓜)

合成大瓜 简介 合成大瓜是使用Flutter+Flame+Forge2D开发的一个开源小游戏。 我在微伞小游戏开发的《合成大西瓜》的基础上将其移植到 Flutter 平台,并添加了以下新特性: 支持自定义背景图 支持重力感应操控 支持修改图片素材 支持反向合成小瓜 支持只生成小/大瓜 内置多套游戏主

null 89 Dec 4, 2022
A simple 2D multiplayer online game built using Flutter and Flame engine

Club Penguin Introduction ?? Club Penguin A multiplayer game involving penguins and anonymous chat in a virtual 2D world Before we start, you can take

Sanjeev Madhav 67 Dec 24, 2022
Dungeon Fantasy - A simple RPG game built with Bonfire and Flame engine

dungeon_fantasy A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Nguyen Minh Dung 1 Dec 28, 2021
🦖 🦖 🦖 Flutter 2D runner game using Flame engine.

t_rex_flame T-rex is the 2D game where you play as a cute little t-rex using Flame engine. All you need do it avoid being hit by enemies too many time

HuongPT 9 Dec 13, 2022
Mason templates for the Flame Engine

Flame Bricks ?? ?? Flame Bricks is a collection of Mason's templates to help people bootstrap classes for the Flame engine. How to use To learn more a

Flame Engine 22 Oct 9, 2022
Game Flutter Using Flame.It was for the Game Jam 2022

binarymemory Memory Binary Flame Flutter Game Jam Getting Started This project is a starting point for a Flutter application. A few resources to get y

Victor Manuel Lagunas Franco 2 Sep 7, 2022
A Dart Tiled library. Parse your TMX files into useful representations. Compatible with Flame.

Tiled Dart A Dart Tiled library. Install from Dart Pub Repository Include the following in your pubspec.yaml: dependencies: tiled: 0.8.1 Usa

Flame Engine 44 Oct 31, 2022
Cyberpunk-inspired puzzle game prototype created with Flutter and Flame #Hack20 #FlutterHackathon

Ghost Rigger Prototype of a cyberpunk-inspired puzzle game set in a dystopian future: In the year 2078, the megacorporation Native Development Initiat

Float like a dash Sting like a dart 184 Dec 26, 2022
A game powered by Flutter and Flame

Flutters About Flutters is a demo game powered by Flutter and Flame. I wrote it to test out its performance and gaming capabilities and decided to ope

Florentin / 珞辰 184 Jan 8, 2023
Game RPG build by Flame Flutter

Darkness Dungeon Game developed for the purpose of testing the use of the Bonfire package! Download APK Used packages: Bonfire - Flame - Used sprites:

Rafael Almeida Barbosa 254 Jan 3, 2023