mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-02 03:15:43 +08:00
Merge branch 'develop' into v1.0.0
This commit is contained in:
@ -4,6 +4,10 @@
|
|||||||
- Move all box2d related code and examples to the flame_box2d repo
|
- Move all box2d related code and examples to the flame_box2d repo
|
||||||
- Rename Animation to SpriteAnimation
|
- Rename Animation to SpriteAnimation
|
||||||
|
|
||||||
|
## 0.26.0
|
||||||
|
- Improving Flame image auto cache
|
||||||
|
- Fix bug in the Box2DGame's add and addLater method , when the Component extends BodyComponent and mixin HasGameRef or other mixins ,the mixins will not be set correctly
|
||||||
|
|
||||||
## 0.25.0
|
## 0.25.0
|
||||||
- Externalizing Tiled support to its own package `flame_tiled`
|
- Externalizing Tiled support to its own package `flame_tiled`
|
||||||
- Preventing some crashs that could happen on web when some methods were called
|
- Preventing some crashs that could happen on web when some methods were called
|
||||||
|
|||||||
@ -18,7 +18,7 @@ Put the pub package as your dependency by dropping the following in your `pubspe
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
dependencies:
|
dependencies:
|
||||||
flame: ^0.25.0
|
flame: ^0.26.0
|
||||||
```
|
```
|
||||||
|
|
||||||
And start using it!
|
And start using it!
|
||||||
|
|||||||
@ -51,6 +51,9 @@ class MyGame extends BaseGame {
|
|||||||
Offset cellSize;
|
Offset cellSize;
|
||||||
Offset halfCellSize;
|
Offset halfCellSize;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool recordFps() => true;
|
||||||
|
|
||||||
MyGame({
|
MyGame({
|
||||||
Size screenSize,
|
Size screenSize,
|
||||||
}) {
|
}) {
|
||||||
@ -292,7 +295,7 @@ class MyGame extends BaseGame {
|
|||||||
Particle imageParticle() {
|
Particle imageParticle() {
|
||||||
return ImageParticle(
|
return ImageParticle(
|
||||||
size: const Size.square(24),
|
size: const Size.square(24),
|
||||||
image: Flame.images.loadedFiles['zap.png'],
|
image: Flame.images.loadedFiles['zap.png'].loadedImage,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,7 +525,7 @@ class MyGame extends BaseGame {
|
|||||||
const rows = 8;
|
const rows = 8;
|
||||||
const frames = columns * rows;
|
const frames = columns * rows;
|
||||||
const imagePath = 'boom3.png';
|
const imagePath = 'boom3.png';
|
||||||
final spriteImage = Flame.images.loadedFiles[imagePath];
|
final spriteImage = Flame.images.loadedFiles[imagePath].loadedImage;
|
||||||
final spritesheet = SpriteSheet(
|
final spritesheet = SpriteSheet(
|
||||||
rows: rows,
|
rows: rows,
|
||||||
columns: columns,
|
columns: columns,
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import 'dart:convert' show base64;
|
|||||||
import 'package:flame/flame.dart';
|
import 'package:flame/flame.dart';
|
||||||
|
|
||||||
class Images {
|
class Images {
|
||||||
Map<String, Image> loadedFiles = {};
|
Map<String, ImageAssetLoader> loadedFiles = {};
|
||||||
|
|
||||||
void clear(String fileName) {
|
void clear(String fileName) {
|
||||||
loadedFiles.remove(fileName);
|
loadedFiles.remove(fileName);
|
||||||
@ -22,16 +22,16 @@ class Images {
|
|||||||
|
|
||||||
Future<Image> load(String fileName) async {
|
Future<Image> load(String fileName) async {
|
||||||
if (!loadedFiles.containsKey(fileName)) {
|
if (!loadedFiles.containsKey(fileName)) {
|
||||||
loadedFiles[fileName] = await _fetchToMemory(fileName);
|
loadedFiles[fileName] = ImageAssetLoader(_fetchToMemory(fileName));
|
||||||
}
|
}
|
||||||
return loadedFiles[fileName];
|
return await loadedFiles[fileName].retreive();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Image> fromBase64(String fileName, String base64) async {
|
Future<Image> fromBase64(String fileName, String base64) async {
|
||||||
if (!loadedFiles.containsKey(fileName)) {
|
if (!loadedFiles.containsKey(fileName)) {
|
||||||
loadedFiles[fileName] = await _fetchFromBase64(base64);
|
loadedFiles[fileName] = ImageAssetLoader(_fetchFromBase64(base64));
|
||||||
}
|
}
|
||||||
return loadedFiles[fileName];
|
return await loadedFiles[fileName].retreive();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Image> _fetchFromBase64(String base64Data) async {
|
Future<Image> _fetchFromBase64(String base64Data) async {
|
||||||
@ -52,3 +52,16 @@ class Images {
|
|||||||
return completer.future;
|
return completer.future;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ImageAssetLoader {
|
||||||
|
ImageAssetLoader(this.future);
|
||||||
|
|
||||||
|
Image loadedImage;
|
||||||
|
Future<Image> future;
|
||||||
|
|
||||||
|
Future<Image> retreive() async {
|
||||||
|
loadedImage ??= await future;
|
||||||
|
|
||||||
|
return loadedImage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
name: flame
|
name: flame
|
||||||
description: A minimalist Flutter game engine, provides a nice set of somewhat independent modules you can choose from.
|
description: A minimalist Flutter game engine, provides a nice set of somewhat independent modules you can choose from.
|
||||||
version: 0.25.0
|
version: 0.26.0
|
||||||
homepage: https://github.com/flame-engine/flame
|
homepage: https://github.com/flame-engine/flame
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
Reference in New Issue
Block a user