总的来说,我对火焰、颤动和飞镖还是很陌生,但我正在尝试使用位于火焰顶部的 Bonfire 插件显示平铺的世界地图,但每当我尝试运行程序时,它都会告诉我存储在 ' 中的值TildWorldMap' 是 String 类型,而不是 double 类型,这是正确的,因为我通过字符串传递了一个 json 文件('tiled/firsttry.json')。我想知道是否还有另一种方法可以将字符串存储为双精度字符串,或者这只是我没有注意到的语法错误?
import 'package:bonfire/bonfire.dart';
import 'package:flutter/material.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
Flame.device.fullScreen();
Flame.device.setLandscape();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return BonfireTiledWidget(
map: TiledWorldMap('tiled/firsttry.json', forceTileSize: Size(16, 16)),
lightingColorGame: Colors.black.withOpacity(0.5),
joystick: Joystick(
directional: JoystickDirectional(
isFixed: false,
)
),
background: BackgroundColorGame(Colors.pinkAccent),
);
}
}