CameraComponent.canSee wasn't performing any kind of sanity checks on the given components world or mounted-ness. This PR adds these checks to correctly return false if the component is not mounted or if the optional world is not the same as camera's current target world.
Creates an axis-aligned bounding box (AABB) around the ray to short-circuit checking.
In the general case, we skip ~75% of the checks because the ray originates at some point in the 2D cartesian space and goes towards infinity. The AABB in that case is a quadrant of space, and so only entities intersecting with this quadrant of space need to be checked.
In the case where the raycast is called with a maxDistance, the savings are much higher. A relatively short ray will generate a small AABB around its origin and end point. In a typical game world, there will be many entities that do not intersect with this AABB, and can be skipped.
`CameraComponent` can now stare at nothingness because its world
reference can be null now.
### Migration instructions
`CameraComponent.world` is now nullable. While accessing it, make sure
to perform null checks if it can be null in your case. Otherwise, if you
are sure that the world is non-null perform unconditional using
`CameraComponent.world!`.
In a project where we wrapped the `JoystickComponent` into it's own
`Component` to separate concerns resizing the window (or hot reloading)
would throw an exception leading to a red screen.
The `HudMarginComponent` currently expects the parent to be either a
`FlameGame` or `ReadOnlySizeProvider`, which throws an exception when
our wrapped `Joystick` class is neither.
With the help of @spydon, we came to the conclusion that this fix should
work and not break other cases.
Apparently someone thought they should run pub get in their terminal instead of flutter pub get. Though it's called "Pub: Get Packages" in the VS Code command pallete.
This changed pub get to flutter pub get in the installation guide (https://docs.flame-engine.org/latest/).
# Description
Add a `Rectangle.fromLTWH` and `Rect.toFlameRectangle` utility methods
to more easily create and convert between different rectangle
represenations.
This PR makes the `PositionEvent` class take a `Game` instance as a
required parameter. The game is the used
to convert `canvasPosition` lazily as it is done in `EventPosition`.
As a result, i had to change several constructor calls to include the
game, and make a breaking change in the `flame_test` package for all the
`create[...]Events` functions. This may not be the best solution, but it
is the easiest. Feel free to share your opinion and improvement ideas.
The Parallax already supported filter quality, but the loader methods were missing parameters for it to be passed to the loaded instances, making it impossible (unless manually loading) to set a filter quality in a parallax.
By setting a filter quality to none (which on flutter means that the next neighbour algorithm will be user) on pixel art sprites we can keep the crisp look that that style of art demands.
Adds a new key api on FCS, which will allow users to get a component from the tree, without needing to iterate over all the children or a parent descendants.
This PR marks SpriteAnimation.ticker() as deprecated with SpriteAnimation.createTicker() as a replacement. This is done to make it more clear that calling that method creates a new ticker. Also, the docs for SpriteAnimationGroupComponent are updated with code snippet showing how to access and use the callbacks from tickers of each animation state.
Add useful methods to Rectangle class for performing geometrical computations:
* a fromCenter constructor
* an `area` getter
* edges and vertices
* intersections with Line Segment
* toRect()
@mustCallSuper is very strict requirement. This is true only for
hitboxes and internal engine's logic, but unnecessary for other,
"client-side" game components.
When overriding `onComponentTypeCheck` for component you can simple
return true or false and this would not break anything.
The update method should end up with the code in this order, otherwise the velocity is never set to 0.
Probably obvious but the rest of the steps were precise on where to include these code blocks.
May wanna add this full block to the end of this step as well, I spent a few minutes trying to figure out why it wasn't working propely.
When updating to the new Flutter & Flame version I was forced to revisit
the occurences of `window.pixelRatio` and realized there is actually a
bug on TextBoxComponent for certain pixelRatios (depending on the size
of the Canvas).
The bug only manifests after a certain pixelRatio for each base size
because while the canvas is created with the unscaled size, it does
appear to be able to "render" outside of it's bounds for the most times.
However I imagine there must be some optimization under the hood, and
after a certain size increment, the rendering is void.
It just removes a deprecated line that is in the tutorial for building a Klondike game. The final code does not have it and it is no longer necessary to have it in the KlondikeGame class.