Merge branch 'develop' into feat/image-base64

This commit is contained in:
Erick
2020-05-05 10:22:31 -03:00
committed by GitHub
3 changed files with 9 additions and 13 deletions

View File

@@ -1,7 +1,8 @@
# CHANGELOG # CHANGELOG
## [next] ## [next]
- Adding method to load image bases on base64 data url. - Adding method to load image bases on base64 data url.
- Fix Box2DGame to follow render priority
## 0.20.0 ## 0.20.0
- Refactor game.dart classes into separate files - Refactor game.dart classes into separate files

View File

@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:box2d_flame/box2d.dart'; import 'package:box2d_flame/box2d.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Flame.util.fullScreen(); await Flame.util.fullScreen();
runApp(GameController().widget); runApp(GameController().widget);
} }
@@ -19,8 +20,8 @@ class MyPlanet extends BodyComponent {
// After 20 seconds the circle will be removed, to show that we don't get // After 20 seconds the circle will be removed, to show that we don't get
// any concurrent modification exceptions. // any concurrent modification exceptions.
MyPlanet(Box2DComponent box) : super(box) { MyPlanet(Box2DComponent box) : super(box) {
Vector2 leftCorner = viewport.getScreenToWorld(Vector2.zero()); Vector2 center = viewport.getScreenToWorld(viewport.center);
_createBody(50.0, leftCorner); _createBody(50.0, center);
} }
void _createBody(double radius, Vector2 position) { void _createBody(double radius, Vector2 position) {
@@ -40,8 +41,7 @@ class MyPlanet extends BodyComponent {
bodyDef.angularVelocity = 4.0; bodyDef.angularVelocity = 4.0;
bodyDef.type = BodyType.DYNAMIC; bodyDef.type = BodyType.DYNAMIC;
this.body = world.createBody(bodyDef) body = world.createBody(bodyDef)..createFixtureFromFixtureDef(fixtureDef);
..createFixtureFromFixtureDef(fixtureDef);
} }
@override @override

View File

@@ -8,7 +8,9 @@ class Box2DGame extends BaseGame {
final Box2DComponent box; final Box2DComponent box;
final List<BodyComponent> _addLater = []; final List<BodyComponent> _addLater = [];
Box2DGame(this.box) : super(); Box2DGame(this.box) : super() {
add(box);
}
@override @override
void add(Component c) { void add(Component c) {
@@ -31,7 +33,6 @@ class Box2DGame extends BaseGame {
@override @override
void update(double t) { void update(double t) {
super.update(t); super.update(t);
box.update(t);
box.components box.components
.where((c) => c.destroy()) .where((c) => c.destroy())
.toList() .toList()
@@ -39,10 +40,4 @@ class Box2DGame extends BaseGame {
box.addAll(_addLater); box.addAll(_addLater);
_addLater.clear(); _addLater.clear();
} }
@override
void render(Canvas c) {
super.render(c);
box.render(c);
}
} }