我对火焰和颤动很陌生,但我只是想为我正在从事的游戏项目建立基础,它告诉我必须初始化字段“screenSize”和“tileSize”。
import 'dart:ui';
import 'package:flame/flame.dart';
import 'package:flame/game.dart';
import 'package:flutter/cupertino.dart';
class GameController extends Game {
Size screenSize;
double tileSize;
GameController() {
initialize();
}
void initialize() async {
resize(await Flame.util.initialDimensions());
}
@override
void render(Canvas canvas) {
Rect background = Rect.fromLTWH(0, 0, screenSize.width, screenSize.height);
Paint backgroundPaint = Paint()..color = Color(0xFFFAFAFA);
canvas.drawRect(background, backgroundPaint);
}
@override
void update(double t) {}
void resize(Size size) {
screenSize = size;
tileSize = screenSize.width / 10;
}
void onTapDown(TapDownDetails d) {
}
}