mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-04 04:47:13 +08:00 
			
		
		
		
	Address comments
This commit is contained in:
		@ -237,17 +237,19 @@ An example of how to use the API can be found [here](/doc/examples/tiled).
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# Isometric Tile Map Component
 | 
					# Isometric Tile Map Component
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This component allows you to render an isometric map based off of a cartesian matrix of blocks and an isometric tileset.
 | 
					This component allows you to render an isometric map based on a cartesian matrix of blocks and an isometric tileset.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
A simple example on how to use it:
 | 
					A simple example on how to use it:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```dart
 | 
					```dart
 | 
				
			||||||
 | 
					  // creates a tileset, the block ids are automatically assigned sequentially starting at 0, from left to right and then top to bottom.
 | 
				
			||||||
  final tileset = await IsometricTileset.load('tileset.png', 32);
 | 
					  final tileset = await IsometricTileset.load('tileset.png', 32);
 | 
				
			||||||
 | 
					  // each element is a block id, -1 means nothing
 | 
				
			||||||
  final matrix = [[0, 1, 0], [1, 0, 0], [1, 1, 1]];
 | 
					  final matrix = [[0, 1, 0], [1, 0, 0], [1, 1, 1]];
 | 
				
			||||||
  add(IsometricTileMapComponent(tileset, matrix));
 | 
					  add(IsometricTileMapComponent(tileset, matrix));
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
It also provides methods to converting coordinates so you can handle clicks, hovers, render entities on top of tiles, add a selector, etc.
 | 
					It also provides methods for converting coordinates so you can handle clicks, hovers, render entities on top of tiles, add a selector, etc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
A more in-depth example can be found [here](/doc/examples/isometric).
 | 
					A more in-depth example can be found [here](/doc/examples/isometric).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										70
									
								
								doc/examples/isometric/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										70
									
								
								doc/examples/isometric/.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1,70 +0,0 @@
 | 
				
			|||||||
# Miscellaneous
 | 
					 | 
				
			||||||
*.class
 | 
					 | 
				
			||||||
*.log
 | 
					 | 
				
			||||||
*.pyc
 | 
					 | 
				
			||||||
*.swp
 | 
					 | 
				
			||||||
.DS_Store
 | 
					 | 
				
			||||||
.atom/
 | 
					 | 
				
			||||||
.buildlog/
 | 
					 | 
				
			||||||
.history
 | 
					 | 
				
			||||||
.svn/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# IntelliJ related
 | 
					 | 
				
			||||||
*.iml
 | 
					 | 
				
			||||||
*.ipr
 | 
					 | 
				
			||||||
*.iws
 | 
					 | 
				
			||||||
.idea/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Visual Studio Code related
 | 
					 | 
				
			||||||
.vscode/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Flutter/Dart/Pub related
 | 
					 | 
				
			||||||
**/doc/api/
 | 
					 | 
				
			||||||
.dart_tool/
 | 
					 | 
				
			||||||
.flutter-plugins
 | 
					 | 
				
			||||||
.packages
 | 
					 | 
				
			||||||
.pub-cache/
 | 
					 | 
				
			||||||
.pub/
 | 
					 | 
				
			||||||
/build/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Android related
 | 
					 | 
				
			||||||
**/android/**/gradle-wrapper.jar
 | 
					 | 
				
			||||||
**/android/.gradle
 | 
					 | 
				
			||||||
**/android/captures/
 | 
					 | 
				
			||||||
**/android/gradlew
 | 
					 | 
				
			||||||
**/android/gradlew.bat
 | 
					 | 
				
			||||||
**/android/local.properties
 | 
					 | 
				
			||||||
**/android/**/GeneratedPluginRegistrant.java
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# iOS/XCode related
 | 
					 | 
				
			||||||
**/ios/**/*.mode1v3
 | 
					 | 
				
			||||||
**/ios/**/*.mode2v3
 | 
					 | 
				
			||||||
**/ios/**/*.moved-aside
 | 
					 | 
				
			||||||
**/ios/**/*.pbxuser
 | 
					 | 
				
			||||||
**/ios/**/*.perspectivev3
 | 
					 | 
				
			||||||
**/ios/**/*sync/
 | 
					 | 
				
			||||||
**/ios/**/.sconsign.dblite
 | 
					 | 
				
			||||||
**/ios/**/.tags*
 | 
					 | 
				
			||||||
**/ios/**/.vagrant/
 | 
					 | 
				
			||||||
**/ios/**/DerivedData/
 | 
					 | 
				
			||||||
**/ios/**/Icon?
 | 
					 | 
				
			||||||
**/ios/**/Pods/
 | 
					 | 
				
			||||||
**/ios/**/.symlinks/
 | 
					 | 
				
			||||||
**/ios/**/profile
 | 
					 | 
				
			||||||
**/ios/**/xcuserdata
 | 
					 | 
				
			||||||
**/ios/.generated/
 | 
					 | 
				
			||||||
**/ios/Flutter/App.framework
 | 
					 | 
				
			||||||
**/ios/Flutter/Flutter.framework
 | 
					 | 
				
			||||||
**/ios/Flutter/Generated.xcconfig
 | 
					 | 
				
			||||||
**/ios/Flutter/app.flx
 | 
					 | 
				
			||||||
**/ios/Flutter/app.zip
 | 
					 | 
				
			||||||
**/ios/Flutter/flutter_assets/
 | 
					 | 
				
			||||||
**/ios/ServiceDefinitions.json
 | 
					 | 
				
			||||||
**/ios/Runner/GeneratedPluginRegistrant.*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Exceptions to above rules.
 | 
					 | 
				
			||||||
!**/ios/**/default.mode1v3
 | 
					 | 
				
			||||||
!**/ios/**/default.mode2v3
 | 
					 | 
				
			||||||
!**/ios/**/default.pbxuser
 | 
					 | 
				
			||||||
!**/ios/**/default.perspectivev3
 | 
					 | 
				
			||||||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
 | 
					 | 
				
			||||||
@ -1,3 +1,3 @@
 | 
				
			|||||||
# isometric
 | 
					# isometric
 | 
				
			||||||
 | 
					
 | 
				
			||||||
A FLame game showcasing how to use the Isometric Tile Map component.
 | 
					A Flame game showcasing how to use the Isometric Tile Map component.
 | 
				
			||||||
 | 
				
			|||||||
@ -27,8 +27,12 @@ class IsometricTileset {
 | 
				
			|||||||
  IsometricTileset(this.tileset, this.size);
 | 
					  IsometricTileset(this.tileset, this.size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// Compute the number of columns the image has
 | 
					  /// Compute the number of columns the image has
 | 
				
			||||||
  /// by using the image width and tile width.
 | 
					  /// by using the image width and tile size.
 | 
				
			||||||
  int get cols => tileset.width ~/ size;
 | 
					  int get columns => tileset.width ~/ size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /// Compute the number of rows the image has
 | 
				
			||||||
 | 
					  /// by using the image height and tile size.
 | 
				
			||||||
 | 
					  int get rows => tileset.height ~/ size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /// Get a sprite to render one specific tile given its id.
 | 
					  /// Get a sprite to render one specific tile given its id.
 | 
				
			||||||
  ///
 | 
					  ///
 | 
				
			||||||
@ -39,8 +43,8 @@ class IsometricTileset {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Sprite _computeTile(int tileId) {
 | 
					  Sprite _computeTile(int tileId) {
 | 
				
			||||||
    final i = tileId % cols;
 | 
					    final i = tileId % columns;
 | 
				
			||||||
    final j = tileId ~/ cols;
 | 
					    final j = tileId ~/ columns;
 | 
				
			||||||
    final s = size.toDouble();
 | 
					    final s = size.toDouble();
 | 
				
			||||||
    return Sprite.fromImage(tileset, x: s * i, y: s * j, width: s, height: s);
 | 
					    return Sprite.fromImage(tileset, x: s * i, y: s * j, width: s, height: s);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user