42 lines
1.3 KiB
Dart
42 lines
1.3 KiB
Dart
import 'package:flame_spine/flame_spine.dart' as spine;
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flame_lua_runtime/flame_lua_runtime.dart';
|
|
|
|
const _serverUrl = String.fromEnvironment('LUA_GAME_SERVER');
|
|
const _gameId = String.fromEnvironment('LUA_GAME_ID', defaultValue: 'showcase');
|
|
const _locale = String.fromEnvironment('LUA_GAME_LOCALE');
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await spine.initSpineFlutter();
|
|
runApp(const FlameLuaRuntimeShowcaseApp());
|
|
}
|
|
|
|
class FlameLuaRuntimeShowcaseApp extends StatelessWidget {
|
|
const FlameLuaRuntimeShowcaseApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
title: 'Flame Lua Runtime Showcase',
|
|
theme: ThemeData.dark(useMaterial3: true),
|
|
home: Scaffold(
|
|
body: SafeArea(
|
|
child: LuaGameWidget(
|
|
gameId: _gameId,
|
|
serverUrl: _serverUrl.isEmpty ? null : Uri.parse(_serverUrl),
|
|
runtimeOptions: const RuntimeOptions(
|
|
runtimeLuaRoot: 'packages/flame_lua_runtime/assets/runtime/lua',
|
|
),
|
|
localeOverride: _locale.isEmpty
|
|
? null
|
|
: RuntimeLocaleResolver.localeFromTag(_locale),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|