This commit fixes the interactive examples of move effect (by and along
path). The were not coming to their original position. This commit fixes
the flower to come to original position when clicked 2nd time. This also
arranges the code in multi line for the move effects in documentation.
* fix!: PolygonComponent no longer modifies _vertices
_vertices passed as first parameter to PolygonComponent constructor
was modified by offsetting all values by the _topLeft vector. This
fix offsets the vectors on demand, so original data is not changed.
Breaking change as PolygonComponent .vertices getter no longer
includes this offset.
* Fixed contains point and intersections.
topLeft offset was being incorrectly applied to globalVertices.
Made topLeft public with @internal to allow its use in CirclePolygonIntersections class.
Public visibility of topLeft also allows previous behaviour of PolygonComponent .vertices to be reproduced by subtracting .topLeft vector from all vectors in new .vertices values.
The three MoveEffects should have small examples that show how the effect is applied and how it works. This could for example be just clicking somewhere in the game and moving a geometrical shape to the position where the reader clicked.
When applying OpacityEffect to a specific paintId, the paint at that id was accidently getting replaced with the default paint. This PR makes sure that color from the provided paintId is used while modifying alpha and opacity in HasPaint mixin.
This PR modifies the Vector2.scaleTo test to use expectDouble instead of expect so as to account for the minor deviation in floating point math.
For the second test, elapsed time of sprite animation was reported as 0.0 after pump() in some cases, causing the test to fail. Even on Linux the elapsed value turns out to be quite small but never reaches zero. For some reason the animation gets reset quite a few time for each pump, causing the elapsed time to get reset to 0. This PR changes the test to check if the animation has started instead of checking is elapsed is non-zero.
Widget test for DragCallbacks and TapCallbacks
Added some common function in separate file for common use case
Minor test case description changed for MultiTouchTapDetector
This PR continues the work for enabling rich text support within Flame.
Here I add support for different text fragments having different TextStyles, and allow those styles to be inheritable within the text node tree.
This PR adds the SpriteFont class, which encapsulates reusable information about a sprite font. Text renderers / text formatters can be created based on this SpriteFont.
In addition:
GlyphInfo removed (was internal), and GlyphData deprecated -- instead, there is now a consolidated Glyph class;
Sprite font now supports extended Unicode characters and ligatures (when a combination of letters is represented as a single glyph)
This feature can also be used to define simple name substitutions. For example, you can declare that "[gp]" or "&gp;" would represent a gold coin icon;
Sprite font supports variable-width fonts;
Sprite font supports glyphs where the source rect is different from the logical rect;
Sprite font renderer can now control the color of the text rendered.
This PR adds an optional parameter to raycast API called maxDistance. Using this parameter users can control the limit within which raycast scans for hits.
This commit makes a few css style changes in order that the language tags for code blocks in documentation site remains same even when horizontally scrolled.
Along with the above, this commit adds right padding to the code as to not come under the language tag when reaching the end.
Allocate an atlas per map to keep sprite paint orders correct. If you
already use one atlas permap, this will have no benifit. Multiple
tileset images will see both a performance gain from single batch
renders, and correct painting on staggered maps.
Fix animations with offets
- Remove TiledLayer._loadImages - no longer used.
- Animations that are in other layers need also translate by offset
Cheap 2D rect bin packing
- Sort: images from large->small
- Keep searching for smallest rect, but input rects should be big->small
Parallel load atlas images
Moved some testing classes around for better code sharing
Fixed tests for external tsx loading. It is dangerous to override global
static values...
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
Fix several errors reported during documentation build.
Generally speaking,
```foo
would be interpreted as a code block with the language foo; while
```{foo}
would be interpreted as a Sphinx directive .. foo.
In order to get notified about a change in a parent's children this new function will be called now.
This feature will help simplifying e.g. the implementation of issue #1944 (Row and Column components).
As seen in #2009 there is an issue in Vector2Extensions
/// Creates a heading [Vector2] with the given angle in radians.
static Vector2 fromRadians(double r) => Vector2.zero()..rotate(r);
/// Creates a heading [Vector2] with the given angle in degrees.
static Vector2 fromDegrees(double d) => fromRadians(d * degrees2Radians);
But this does nothing as the rotate method does nothing on zero
void rotate(double angle, {Vector2? center}) {
if (isZero() || angle == 0) {
// No point in rotating the zero vector or to rotate with 0 as angle
return;
}
...
}
Solution : Change Vector2.zero() to Vector2(0, -1) in Vector2Extensions.fromRadians
Also added unit tests to make sure it works fine.
Also, I created a new component based on Spydon's request. Ember is now an extendable class for these examples. You can override the onTap method and I suspect we can extend collision or any other method that is needed for more interactive examples.
This almost exactly like the current HasGameRef mixin, except that:
The property is called game instead of gameRef (the "gameRef" violates Dart naming conventions against using abbreviations in variable names);
The template type T supports all Games, not only FlameGames;
Better integration with the SingleGameInstance mixin;
The new mixin is within experimental, to reduce chance that it will confuse the users.
melos doc-xyz commands were not working on Windows as SOURCEDIR was not properly getting set. I tried changing it to use set SOURCEDIR="$MELOS_ROOT_PATH/doc" and set SOURCEDIR="%MELOS_ROOT_PATH%/doc", but both didn't work. As SOURCEDIR isn't really necessary to be set for the commands to work, this PR remove that variable and directly using $MELOS_ROOT_PATH/doc in its place.
Additionally, this PR also adds .venv (a common folder storing virtual env) to gitignore.
onComponentTypeCheck was only supported for components but not for hitboxes, because ShapeHitbox implements GenericCollisionCallbacks instead CollisionCallbacks.
Specifying onComponentTypeCheck for individual hitboxes might be useful in cases where Component have hitboxes for collisions and also some utility hitboxes (for example, to check available directions for pathfinding). Colliding between this two types of hitboxes should not lead to movement restrictions and so on. But without onComponentTypeCheck in ShapeHitbox we can not to perform such check.