In the test, the component was not properly added to a game instance, and as a result its hitbox was never mounted. In addition, the hitbox polygon used negative coordinates, which caused to be outside of the parent shape, which was counterintuitive.
In Sphinx, there is a concept of a "domain", which enables documenting library object such as classes and functions, and then referencing them from any other place in the documentation. This PR adds such a domain for the Dart language.
With the new approach, a class/function can be documented using the following directive:
```{dartdoc}
📦 flame
:symbol: GameWidget
:file: src/game/game_widget/game_widget.dart
```
The documentation will then be automatically extracted from the referenced file using the dartdoc_json tool (published as a separate package), and then rendered inside the page. The screenshot below shows an example of how DialogueRunner class from Jenny would be rendered:
<image>
Once a symbol has been documented using the dartdoc directive, it can be referenced from other places in the documentation as
{ref}`DialogueRunner`
items variable from core Broadphase class is replaced to abstract getter. Also methods for adding and removing items are added. All this together allows to preserve backward compatibility and allow broadphase / collision detection developer to specify own algorithm of adding/removing hitboxes and algorithm of accessing a full list of hitboxes.
This fixes the following warning when running our CI workflows:
[!] The "format" command is deprecated and will be removed in a future version of
Flutter. Please use the "dart format" sub-command instead, which takes all of the
same command-line arguments as "flutter format".
We overrode the add() method in the FlameMultiBlocProvider to handle a new functionality (add the new component to the last provider). We need to apply this functionality to the remove() method too. I just overrode the remove() method to apply that functionality.
In this way, both of add() and remove() methods work consistently.
The new command allows pre-declaring the characters that will be seen in the yarn scripts, and provides a place to store any additional information associated with each character.
The DialogueLine.character property now returns a Character object, instead of a String.
Currently if you navigate to any inner page on the documentation site, say https://docs.flame-engine.org/main/tutorials/platformer/step_5.html, then the menus on the left that are currently collapsed can be expanded, but those that are already expanded cannot be collapsed (try clicking on the arrow next to "Tutorials" or "Ember Quest"). This PR fixes that.
The new property camera.visibleWorldRect gives the Aabb of the world region visible through the camera. This can be useful for culling the render pipeline, or similar purposes.
The YarnSpinner language supports variables of type numeric, but not integers or doubles. The closest concept in Dart is the num type, which is a union of int and double. However, we need to make sure that a number stringifies in a consistent manner regardless of whether its underlying representation is integer or double. Thus, we must make sure that 12 and 12.0 not only compare equal (which they already do), but also have the same representation when converted to string.
This PR ensures that any integer-like double looks like an integer when converted to a string.
This PR adds the aforementioned methods to the router component so a user can replace the current route / overlay with something else without having to call pop then push. Additionally, it corrects an error in the router documents as popPage() does not exist as the call is just pop().
This PR adds missing documentation for all built-in functions available in Jenny.
In addition:
The bool() function now behaves the same way as the conversion of arguments for an invocation of a user-defined function;
Consequently, static sets trueValues/falseValues moved from CommandStorage class into the YarnProject;
Added some tests for several other functions.
Since we used setMounted in onGameResize the mounted feature didn't work properly when invoked from for example onLoad. This PR makes sure that all tests passes without using setMounted in onLoad.
Some GameWidget tests I want a second opinion on, or ideas of how to make those tests better, because when setting mounted explicitly it kind of cheats on part of those tests.
Adds a link to https://zapp.run/edit/flame-zh006agh106 in the issue template, since Flame is already set up in there it is incredibly easy to share and run MREs from there.
We shouldn't teach our users to create new Rect objects in render.
Also switching to onTapDown since onTapUp won't trigger if you move the mouse since it'll be a drag event instead.
Forge2D/Box2D doesn't have a concept of nested bodies and all bodies should live on a top level in the physics world. However, it's hard to know this for people who stat with Forge2d right away. It would be nice to have it clearly mentioned in the documentations.
Closes#2240
The functionality of the <<visit Target>> command is that the dialogue runner will temporarily suspend execution of the current node and start executing Target, but then once that finishes it will resume executing the original node.
Previously, onDialogueChoice was returning a never-completing future, which is both more error-prone, and prevents a use-case where a dialogue view would perform some async action without ultimately making a selection.
Before this PR, the return type of onLoad() was Future<void>?, after this PR the return type is FutureOr<void> -- both for classes Component and Game.
Reasons:
The use of FutureOr is more idiomatic in Dart, this class was specifically created in order to be used in situations like ours.
This makes learning Flame easier for beginners, since you no longer need to explain what asynchronous programming is from the start (and onLoad() is one of the first methods the user encounters in Flame).
The code can be cleaner in case when onLoad doesn't need to be async.
With new approach, the onLoad() method can be overridden as either
@override
Future<void> onLoad() async { ... }
or
@override
void onLoad() { ... }
Of course, it can also be overridden as
@override
FutureOr<void> onLoad() { ... }
but this is rare, only for components that are designed to be further subclassed, or for mixins.
The documentation was updated to show the new recommended usage.
The onNodeFinish event is a counterpart to onNodeStart.
This also fixes a small bug where node visit count was not properly incremented if the node was exited via a <<stop>>.
The DialogueRunner.runNode() method renamed into startDialogue().
Include the list of allowed Conventional Commit prefixes into the PR template, and into the title validator action; otherwise this information is too hard to hunt down (https://github.com/commitizen/conventional-commit-types/blob/master/index.json)
The title validator now checks that the PR title starts with a capital letter.
Removed checklist item "The title of my PR starts with a Conventional Prefix", since this is now enforced automatically.