Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// ignore: depend_on_referenced_packages
import 'package:collection/collection.dart';
import 'package:flame/camera.dart';
import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:flame_ldtk/flame_ldtk.dart';
Expand Down Expand Up @@ -55,7 +56,7 @@ class LdtkGame extends FlameGame {
// final coins = await Flame.images.load('coins.png');

// camera.zoom = .5;
camera.viewport = FixedResolutionViewport(Vector2(512, 256));
camera.viewport = FixedResolutionViewport( resolution: Vector2(512, 256),);

// We are 100% sure that an object layer named `AnimatedCoins`
// exists in the example `map.tmx`.
Expand Down Expand Up @@ -86,7 +87,7 @@ class LdtkGame extends FlameGame {

// Pan the camera down and right for 10 seconds, then reverse
if (time % 20 < 10) {
cameraTarget = mapComponent.size - camera.viewport.effectiveSize;
cameraTarget = mapComponent.size - camera.viewport.size;
} else {
cameraTarget.setZero();
}
Expand Down
38 changes: 15 additions & 23 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ packages:
dependency: transitive
description:
name: characters
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
url: "https://pub.dev"
source: hosted
version: "1.2.1"
version: "1.4.0"
collection:
dependency: transitive
description:
name: collection
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
url: "https://pub.dev"
source: hosted
version: "1.17.0"
version: "1.19.1"
flame:
dependency: "direct main"
description:
name: flame
sha256: "0c55f8d704f09536125c811a19d9aab7407dce245b2bfb507e84296c1c996202"
sha256: f9e7a100c25f8d6bfd143bf325a9689c509216cd1c8133ce4684955c56770de7
url: "https://pub.dev"
source: hosted
version: "1.6.0"
version: "1.28.1"
flame_ldtk:
dependency: "direct main"
description:
Expand All @@ -45,14 +45,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
description:
name: js
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
url: "https://pub.dev"
source: hosted
version: "0.6.5"
ldtk:
dependency: transitive
description:
Expand All @@ -66,31 +58,31 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
url: "https://pub.dev"
source: hosted
version: "1.8.0"
version: "1.16.0"
ordered_set:
dependency: transitive
description:
name: ordered_set
sha256: "74b0454418f58c34c8e527d91fb1ef571297dbcd5d3b4e5f983dc884e39cdf85"
sha256: dc68b8f1abc7115b81cf890bf7d2ece4ed1d95e0f3e486ab4b64ab3d16d2ea42
url: "https://pub.dev"
source: hosted
version: "5.0.0"
version: "7.0.0"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
version: "0.0.0"
vector_math:
dependency: transitive
description:
Expand All @@ -100,5 +92,5 @@ packages:
source: hosted
version: "2.1.4"
sdks:
dart: ">=2.18.2 <3.0.0"
flutter: ">=3.3.0"
dart: ">=3.7.0-0 <4.0.0"
flutter: ">=3.27.1"
7 changes: 6 additions & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ environment:
sdk: ">=2.17.0 <3.0.0"

dependencies:
flame: ^1.6.0
flame: ^1.28.1
flame_ldtk:
path: ../
flutter:
Expand All @@ -19,3 +19,8 @@ flutter:
uses-material-design: true
assets:
- assets/
- assets/ldtk/
- assets/ldtk/atlas/
- assets/ldtk/linear/
- assets/ldtk/map_4/
- assets/ldtk/third_map/
Binary file modified lib/.DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions lib/src/ldtk_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import 'package:meta/meta.dart';
///
/// {@endtemplate}
class LdtkComponent<T extends FlameGame> extends PositionComponent
with HasGameRef<T> {
with HasGameReference<T> {
/// {@macro _ldtk_component}
LdtkComponent(
this.tileMap, {
Expand Down Expand Up @@ -84,7 +84,7 @@ class LdtkComponent<T extends FlameGame> extends PositionComponent
Future<void>? onLoad() async {
super.onLoad();
// Automatically use the FlameGame camera if it's not already set.
tileMap.camera ??= gameRef.camera;
tileMap.camera ??= game.camera;
}

@override
Expand All @@ -108,7 +108,7 @@ class LdtkComponent<T extends FlameGame> extends PositionComponent
static Future<LdtkComponent> load(
String fileName, {
int? priority,
Camera? camera,
CameraComponent? camera,
bool simpleMode = false,
bool compositeAllLevels = false,
}) async {
Expand Down
6 changes: 2 additions & 4 deletions lib/src/renderable_tile_map.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'dart:math';
import 'dart:ui';

Expand Down Expand Up @@ -34,7 +33,7 @@ class RenderableLdtkMap {

/// Camera used for determining the current viewport for layer rendering.
/// Optional, but required for parallax support
Camera? camera;
CameraComponent? camera;

/// Local path for the main .ldtk file, used to get the path of tileset
/// images, and will support external .ldtkl levels in the future
Expand Down Expand Up @@ -88,7 +87,6 @@ class RenderableLdtkMap {

final ldtkPath = Uri.file(
'assets/ldtk/$fileName',
windows: Platform.isWindows,
);
final ldtkProjectName = fileName.substring(0, fileName.length - 5);

Expand All @@ -107,7 +105,7 @@ class RenderableLdtkMap {
Image? image;
if (tileset.embedAtlas != EmbedAtlas.LDTK_ICONS) {
image = await (Flame.images..prefix = '').load(
tilesetImagePath.toFilePath(windows: Platform.isWindows),
tilesetImagePath.toFilePath(),
);
tilesetsDefinitions[tileset.uid ?? -1] = image;
}
Expand Down
Loading