-
-
Notifications
You must be signed in to change notification settings - Fork 899
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Animated tile support! (#1930)
Tiled supports animated tiles, and now Flame does as well...
- Loading branch information
Showing
47 changed files
with
1,042 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<tileset version="1.9" tiledversion="1.9.2" name="0x72_DungeonTilesetII_v1.4" tilewidth="16" tileheight="16" tilecount="1024" columns="32"> | ||
<image source="../images/0x72_DungeonTilesetII_v1.4.png" width="512" height="512"/> | ||
<tile id="36"> | ||
<animation> | ||
<frame tileid="36" duration="180"/> | ||
<frame tileid="37" duration="180"/> | ||
<frame tileid="38" duration="180"/> | ||
</animation> | ||
</tile> | ||
<tile id="68"> | ||
<animation> | ||
<frame tileid="68" duration="180"/> | ||
<frame tileid="69" duration="180"/> | ||
<frame tileid="70" duration="180"/> | ||
</animation> | ||
</tile> | ||
<tile id="100"> | ||
<animation> | ||
<frame tileid="100" duration="180"/> | ||
<frame tileid="101" duration="180"/> | ||
<frame tileid="102" duration="180"/> | ||
</animation> | ||
</tile> | ||
<tile id="132"> | ||
<animation> | ||
<frame tileid="132" duration="180"/> | ||
<frame tileid="133" duration="180"/> | ||
<frame tileid="134" duration="180"/> | ||
</animation> | ||
</tile> | ||
<tile id="356"> | ||
<animation> | ||
<frame tileid="353" duration="70"/> | ||
<frame tileid="354" duration="70"/> | ||
<frame tileid="355" duration="70"/> | ||
<frame tileid="356" duration="70"/> | ||
<frame tileid="355" duration="70"/> | ||
<frame tileid="354" duration="70"/> | ||
</animation> | ||
</tile> | ||
<tile id="368"> | ||
<animation> | ||
<frame tileid="44" duration="130"/> | ||
<frame tileid="45" duration="130"/> | ||
<frame tileid="46" duration="130"/> | ||
<frame tileid="47" duration="130"/> | ||
<frame tileid="48" duration="130"/> | ||
</animation> | ||
</tile> | ||
<tile id="496"> | ||
<animation> | ||
<frame tileid="488" duration="210"/> | ||
<frame tileid="489" duration="210"/> | ||
<frame tileid="490" duration="210"/> | ||
<frame tileid="491" duration="210"/> | ||
</animation> | ||
</tile> | ||
<tile id="627"> | ||
<animation> | ||
<frame tileid="627" duration="210"/> | ||
<frame tileid="628" duration="210"/> | ||
<frame tileid="629" duration="210"/> | ||
<frame tileid="628" duration="210"/> | ||
</animation> | ||
</tile> | ||
<tile id="659"> | ||
<animation> | ||
<frame tileid="659" duration="210"/> | ||
<frame tileid="660" duration="210"/> | ||
<frame tileid="661" duration="210"/> | ||
</animation> | ||
</tile> | ||
</tileset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<map version="1.9" tiledversion="1.9.2" orientation="orthogonal" renderorder="right-down" width="10" height="10" tilewidth="16" tileheight="16" infinite="0" nextlayerid="6" nextobjectid="1"> | ||
<tileset firstgid="1" source="0x72_DungeonTilesetII_v1.4.tsx"/> | ||
<layer id="3" name="ground" width="10" height="10" locked="1"> | ||
<data encoding="base64" compression="gzip"> | ||
H4sIAAAAAAAACmNgoAw0Y6FHMfkYAK7z31GQAQAA | ||
</data> | ||
</layer> | ||
<layer id="1" name="walls" width="10" height="10"> | ||
<data encoding="base64" compression="gzip"> | ||
H4sIAAAAAAAACp3Q7QmDMBSF4ZuELFIVF9FNdBQXae0i4scegnYNXzDgKfSH9MJDksPh/og3My+i0Dw4s4ddiqTVjI6HTp10krkfPZ3xZu/uvn97Zeo+OV/o8XbfvQzBTgP3GQsmyaP8XYOV944PNuRkFTIcCfCt35ABAAA= | ||
</data> | ||
</layer> | ||
<layer id="4" name="stuff" width="10" height="10"> | ||
<data encoding="base64" compression="gzip"> | ||
H4sIAAAAAAAACmNgoA0oYaKNuamMuOW2IqmBYRgwQ2JfxWHeFKCbw/CYTw8AANEJHwqQAQAA | ||
</data> | ||
</layer> | ||
</map> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
examples/lib/stories/tiled/flame_tiled_animation_example.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:flame/game.dart'; | ||
import 'package:flame_tiled/flame_tiled.dart'; | ||
|
||
class FlameTiledAnimationExample extends FlameGame { | ||
static const String description = ''' | ||
Loads and displays an animated Tiled map. | ||
'''; | ||
|
||
late final TiledComponent map; | ||
|
||
@override | ||
Future<void> onLoad() async { | ||
map = await TiledComponent.load('dungeon.tmx', Vector2.all(32)); | ||
add(map); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:dashbook/dashbook.dart'; | ||
import 'package:examples/commons/commons.dart'; | ||
import 'package:examples/stories/tiled/flame_tiled_animation_example.dart'; | ||
|
||
import 'package:flame/game.dart'; | ||
|
||
void addTiledStories(Dashbook dashbook) { | ||
dashbook.storiesOf('Tiled').add( | ||
'Flame Tiled Animation', | ||
(_) => GameWidget(game: FlameTiledAnimationExample()), | ||
codeLink: baseLink('effects/flame_tiled_animation_example.dart'), | ||
info: FlameTiledAnimationExample.description, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'dart:ui' show Rect; | ||
|
||
/// A mutable version of [Rect] for tile map animations. | ||
class MutableRect extends Rect { | ||
/// Construct a rectangle from its left, top, right, and bottom edges. | ||
MutableRect.fromLTRB(this.left, this.top, this.right, this.bottom) | ||
: super.fromLTRB(left, top, right, bottom); | ||
|
||
/// Create a new instance from [other]. | ||
factory MutableRect.fromRect(Rect other) => | ||
MutableRect.fromLTRB(other.left, other.top, other.right, other.bottom); | ||
|
||
/// The offset of the left edge of this rectangle from the x axis. | ||
@override | ||
double left; | ||
|
||
/// The offset of the top edge of this rectangle from the y axis. | ||
@override | ||
double top; | ||
|
||
/// The offset of the right edge of this rectangle from the x axis. | ||
@override | ||
double right; | ||
|
||
/// The offset of the bottom edge of this rectangle from the y axis. | ||
@override | ||
double bottom; | ||
|
||
/// Update with [other]'s dimensions. | ||
void copy(Rect other) { | ||
left = other.left; | ||
top = other.top; | ||
right = other.right; | ||
bottom = other.bottom; | ||
} | ||
|
||
/// Convert to immutable rectangle. | ||
Rect toRect() => Rect.fromLTRB(left, top, right, bottom); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.