休闲游戏工具包
了解在 Flutter 中进行免费开源多平台 2D 游戏开发。
Flutter 休闲游戏工具包整合新旧资源,帮助你在移动平台上加速游戏开发。
本页概述这些可用资源的位置。
为何用 Flutter 做游戏?
#Flutter 框架可为从桌面、移动设备到 Web 的六个目标平台创建高性能应用。
凭借跨平台开发、性能和开源许可等优势,Flutter 非常适合做游戏。
休闲游戏分为两类:回合制游戏和实时游戏。你可能熟悉这两类游戏,只是未必这样划分。
回合制游戏 面向大众市场,规则与玩法简单,包括棋类、卡牌、益智和策略游戏。它们响应轻触卡牌或输入数字、字母等简单输入,很适合用 Flutter。
实时游戏 需要实时响应一系列操作,包括无尽跑酷、赛车等。你可能想实现碰撞检测、镜头、游戏循环等高级特性,这类游戏可使用基于 Flutter 构建的开源引擎,如 Flame game engine。
工具包包含什么
#休闲游戏工具包提供以下免费资源。
-
A repository that includes three game templates that provide a starting point for building a casual game.
-
一个仓库,包含三个游戏模板,作为构建休闲游戏的起点。
A base game template that includes the basics for:
base game template(基础游戏模板),包含:
Main menu
主菜单
Navigation
导航
Settings
设置
Level selection
关卡选择
Player progress
玩家进度
Play session management
游戏会话管理
Sound
音效
Themes
主题
A card game template that includes everything in the base template plus:
card game template(卡牌游戏模板),包含基础模板全部内容,另加:
Drag and drop
拖放
Game state management
游戏状态管理
Multiplayer integration hooks
多人集成钩子
An endless runner template created in partnership with the open source game engine, Flame. It implements:
与开源引擎 Flame 合作创建的 endless runner template(无尽跑酷模板),实现:
A FlameGame base template
FlameGame 基础模板
Player steering
玩家操控
Collision detection
碰撞检测
Parallax effects
视差效果
Spawning
生成
Different visual effects
多种视觉效果
A sample game built on top of the endless runner template, called SuperDash. You can play the game on iOS, Android, or web, view the open source code repo, or read how the game was created in 6 weeks.
基于无尽跑酷模板的示例游戏 SuperDash。可在 iOS、Android 或 web 上游玩,view the open source code repo(查看开源代码仓库),或 read how the game was created in 6 weeks(阅读如何在 6 周内完成)。
Developer guides for integrating needed services.
集成所需服务的开发者指南。
-
A link to a Flame Discord channel. If you have a Discord account, use this direct link.
-
Flame Discord 频道链接。若有 Discord 账号,可使用此 direct link(直接链接)。
包含的游戏模板和 cookbook 食谱为加速开发做了特定选择,使用 provider、google_mobile_ads、in_app_purchase、audioplayers、crashlytics、games_services
等包。若你偏好其他包,可修改代码替换。
Flutter 团队理解变现可能是未来考量,已添加广告与应用内购买的 cookbook 食谱。
如 Games 页所述,将 Cloud, Firebase 和 Ads 等 Google 服务集成到游戏中,最高可利用约 $900 优惠。
入门
#准备好了吗?按以下步骤开始:
If you haven't done so, install Flutter.
若尚未安装,请 install Flutter(安装 Flutter)。
Clone the games repo(克隆游戏仓库)。
Review the
READMEfile for the first type of game you want to create.-
查看你想创建的第一类游戏对应的
README文件。basic game(基础游戏)
card game(卡牌游戏)
runner game(跑酷游戏)
-
Join the Flame community on Discord (use the direct link if you already have a Discord account).
-
Join the Flame community on Discord(加入 Flame Discord 社区)(若已有 Discord 账号可使用 direct link)。
Review the codelabs and cookbook recipes.
-
查阅 codelab 与 cookbook 食谱。
Build a multiplayer game with Cloud Firestore.
使用 Cloud Firestore 构建 multiplayer game(多人游戏)。
Build a word puzzle with Flutter.
用 Flutter 构建 word puzzle(填字游戏)。
Make your games more engaging with leaderboards and achievements.
通过 leaderboards and achievements(排行榜与成就)提升游戏吸引力。
Monetize your games with in-game ads and in-app purchases.
用 in-game ads(游戏内广告)和 in-app purchases(应用内购买)变现。
Add user authentication flow to your game with Firebase Authentication.
用 Firebase Authentication 为游戏添加用户认证流程。
Collect analytics about crashes and errors inside your game with Firebase Crashlytics.
用 Firebase Crashlytics 收集游戏内崩溃与错误分析。
Set up accounts on AdMob, Firebase, and Cloud, as needed.
按需设置 AdMob、Firebase 和 Cloud 账号。
Write your game!
编写你的游戏!
Deploy to both the Google Play and Apple stores.
部署到 Google Play 和 Apple 商店。
示例游戏
#在 Google I/O 2022,Flutter 团队与 Very Good Ventures 都发布了新游戏。
-
VGV created the I/O Pinball game using the Flame engine. To learn about this game, check out I/O Pinball Powered by Flutter and Firebase on Medium and play the game in your browser.
-
VGV 使用 Flame 引擎创建 I/O Pinball game。在 Medium 阅读 I/O Pinball Powered by Flutter and Firebase,并在浏览器 play the game(试玩)。
-
The Flutter team created I/O Flip, a virtual CCG. To learn more about I/O Flip, check out How It's Made: I/O FLIP adds a twist to a classic card game with generative AI on the Google Developers blog and play the game in your browser.
-
Flutter 团队创建虚拟 CCG I/O Flip。在 Google Developers 博客阅读 How It's Made: I/O FLIP adds a twist to a classic card game with generative AI,并在浏览器 play the game(试玩)。
其他资源
#当你准备超越这些游戏模板时,可探索社区推荐的其他资源。
其他资源
#请观看以下视频:
-
Building multiplatform games with Flutter, a talk given at the Game Developer Conference (GDC) 2024.
-
Building multiplatform games with Flutter(使用 Flutter 构建多平台游戏),Game Developer Conference (GDC) 2024 演讲。
-
How to build a physics-based game with Flutter and Flame's Forge2D, from Google I/O 2024.
-
How to build a physics-based game with Flutter and Flame's Forge2D(如何使用 Flutter 与 Flame 的 Forge2D 构建物理游戏),来自 Google I/O 2024。
除非另有说明,本文档之所提及适用于 Flutter 3.44.0 版本。本页面最后更新时间:2026-06-04。查看文档源码 或者 为本页面内容提出建议。