-
-
Notifications
You must be signed in to change notification settings - Fork 908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix!: Update IsometricTileMapComponent to have better defined position and size #3142
Conversation
@@ -101,6 +104,11 @@ class IsometricTileMapComponent extends PositionComponent { | |||
} | |||
} | |||
|
|||
@override | |||
void update(double dt) { | |||
_recomputeSize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since the block matrix is not final, theoretically it could be changed at any time. luckily recomputing the size is quite cheap so I think this should be fine.
dbb7717
to
258fabe
Compare
packages/flame/lib/src/components/isometric_tile_map_component.dart
Outdated
Show resolved
Hide resolved
packages/flame/lib/src/components/isometric_tile_map_component.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Lgtm
Description
Update IsometricTileMapComponent to have better defined position and size.
Before, the isometric component "zero" would be the center of the 0,0 block.
However, that does not play nicely with our component system if you want to know the size (i.e. bounding box) of a component.
This changes so that the 0,0 of the component is the 0,0 of the AABB around the isometric tiles. Then, it also computes the size of the component accordingly.
This also changes the example to allow toggling between half and full size more easily.
In our example, this is what it looks like:
The example still shows how to compute the previous origin (the purple dot) if you want to.
With full size blocks:
I also updated isomash to check if more complex functionality plays well with the new system:
Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Breaking Change?
Migration instructions
This is a minor breaking change as you might need to "reposition" your tile components, essentially remove the "compensation" for its location that you probably did yourself. If you were centering the tile component based on the available methods such as
map.getBlockCenterPosition
, then just make sure you are adding themap.position
to that and it should work as before.