Commit Graph

3302 Commits

Author SHA1 Message Date
Luan Nico
cd2b2a1097 refactor: Remove unused variable "tapTimes" from multi_touch_tap_detector_test.dart (#2379)
This is a cleanup identified on this issue: #2308
Using an amazing unused-code tooling
Now, since Flame is a public API, unused code might not be trivial - it might just mean untested code.

This one was a no-brainer -- the variable was clearly replaced by specific counters during the writing of the test and forgotten there:

  int nOnTapDown = 0;
  int nOnLongTapDown = 0;
  int nOnTapUp = 0;
  int nOnTap = 0;
  int nOnTapCancel = 0;

It wasn't even increment and the taps are already thoroughly tested more granularly
2023-03-01 09:40:30 +00:00
Luan Nico
1431e60c9c docs: Clarify required flutter channel on CONTRIBUTING guidelines (#2376)
Clarify required flutter channel on CONTRIBUTING guidelines
2023-03-01 10:29:06 +01:00
Jehun Seem(심제훈)
181e0b59fd feat: Add position and anchor params for Sprite and SpriteAnimation Particles (#2370) 2023-02-28 12:34:58 +01:00
Eugene Kleshnin
5b07bd58f3 docs: DistanceJoint documentation and example (#2369)
DistanceJoint documentation and example
2023-02-27 22:29:07 +01:00
Lukas Klingsbo
3125087c2e docs: Add missing dictionary words (#2372)
All of a sudden Cypher started failing in the pipeline.
The other two are for #2367
2023-02-27 17:18:57 +00:00
Lukas Klingsbo
79bfeee3fe docs: Fix invite link to Discord in docs top bar (#2371)
The link went directly to the Flame channel instead of being an invite link to the server, so it didn't work for people that weren't already on the server.
2023-02-27 18:02:14 +01:00
Pasha Stetsenko
1ef518794c refactor: Component rebalancing is now performed via a global queue (#2352)
This PR ensures that all component rebalancing operations are resolved from a single location, after the update stage but before the render stage (thus, components may get reordered during the update, and these changes will go into effect during the rendering step on the same game tick).

This also fixes the problem where the child changing the priorities of its parent would cause a ConcurrentModificationError.

A number of methods that were used to handle rebalancing are now marked as deprecated. From the user's perspective, the only API they should be using is the .priority setter.
2023-02-27 00:45:27 +01:00
Lukas Klingsbo
093a1abb07 docs: Update to latest sphinx-mermaid (#2368)
This fixes the regression with that the graphs aren't rendering.
Unfortunately they will forever be broken in the v1.6.0 release of the
docs now.

Fix comes from here:
2eaff4220a
2023-02-26 15:16:28 +01:00
Eugene Kleshnin
957ad2402a docs: Added a page for Joints documentation + ConstantVolumeJoint doc and example (#2362)
Added a page for Forge2D joints documentation.
Added a `ConstantVolumeJoint` documentation and example.

Will add other joint types in the next PRs.
2023-02-26 13:33:22 +01:00
Eugene Kleshnin
a681c70fb4 docs: Updated activate melos command (#2366)
Updated activate melos command, to use melos 3.0
2023-02-25 22:09:03 +00:00
Victor Eronmosele
d1c94d9cfa docs: Fix typo in Step 3 of platformer tutorial (#2363)
The grid position variable is non-private: gridPosition in the PlatformBlock class definition but was used as private: _gridPosition in the onLoad method.

This PR updates the grid position variable in the onLoad to gridPosition.
2023-02-23 06:25:01 +01:00
Hwanseok Barth Kang
73467c941d feat: Use cached image when creating single source TiledAtlas if available (#2348)
Detailed use-case examples are described in #2337.
As-is

    A single source TiledAtlas doesn't check if there is a cached image that is already loaded in the memory.
    It re-loads the image into the memory.

To-be

    A single source TiledAtlas now uses the cached image if it exists.
2023-02-22 09:38:55 +00:00
Pasha Stetsenko
f58a616cdf feat: Show component tree in Flame Studio (#2339)
Add ability to display game's component tree in the left panel.
The tree automatically re-syncs with the game every 300ms (eventually this should be a configurable value).
Nested parts of the tree can be expanded/collapsed, and one component can be selected.
In the future, the selected component can be shown in the Inspector, but that is not implemented yet.
2023-02-22 10:28:57 +01:00
Jonatas Emidio
c2ba1fc65f docs: Fixing components sub-directory path (#2359)
At the *Other classes* session, when it is mentioned that we need to
create the `components` sub-directory, the tutorial is guiding us to add
it in the root, but on the structure below, it is possible to see that
it should be created inside the `libs` folder instead.

It seems to be better to be more explicit in this paragraph.
2023-02-21 21:42:32 +01:00
Hugo Delaunay
4e0a8c4688 feat: Make limit field mutable in the Timer class (#2358)
As stated in #2357, the field `limit` of the class `Timer` had no reason
to be final. By removing this keyword, we make it possible to add more
time to a given `Timer` object (so that they can be used as a countdown
for example).
2023-02-21 19:01:03 +00:00
Lukas Klingsbo
ecea91661f docs: Small anchor confusion in the components doc (#2356)
Seems to have been some confusion about the anchor from the one that
wrote these docs, the sentence that described the code was wrong.
2023-02-21 11:19:21 -05:00
Lukas Klingsbo
38e8758a85 docs: Indentation fix in gesture list (#2355)
Minor indentation fix in the list of gesture detectors.
2023-02-20 11:28:26 -05:00
Caio Pedroso
5af60cf80c docs: Fix broken links in Component Notifier examples (#2351)
Current source code links for Component Notifier and Component Notifier (with provider) return 404, this PR fixes it.
2023-02-20 08:45:50 +00:00
Norberto Martín Afonso
f993261c74 chore: Update rive package to 0.10.2 (#2349)
0.10.2:

Performance improvement: No longer drawing components with an opacity of 0.
Updated example, see "Skinning Demo".
Support for negative speeds on linear animations when played back in state machines.
Support for overriding speed on animation states.
2023-02-19 16:01:07 +01:00
Pasha Stetsenko
655824fc00 docs: Refactor documentation for GameWidget (#2344)
Use the dartdoc directive for the GameWidget class, allowing us to keep the documentation in the code and on the site in sync.
2023-02-17 13:39:13 +01:00
Renan
b6aeec24d7 feat: Allow people to opt-out on repaint boundary (#2341) 2023-02-14 18:28:56 +00:00
Gustl22
3f9e65943f docs: link cicd badge with GH workflow results (#2342)
Link cicd badge with GH workflow results.
2023-02-14 16:36:21 +01:00
Pasha Stetsenko
4ec4e34cc6 feat: Initial version of flame_studio package (#2331)
This is the beginning of work on Flame Studio. In this PR we add a simple UI, which shows the game itself, an info panel, and a toolbar with 2 buttons: start/pause. The UI is able to control the embedded game; in particular the toolbar buttons can pause or resume the game engine.
2023-02-13 22:12:16 +01:00
Lukas Klingsbo
65091f34bf docs: Add Flame logo for pub.dev (#2338)
There is a new feature on pub.dev where you can add your logo or screenshots of examples to your pub.dev listing.
In this PR I'm just adding the Flame logo for the Flame core package.

Example of how it looks like for Bloc:
https://pub.dev/packages/bloc
2023-02-13 08:43:46 +01:00
Victor Eronmosele
7c7d2e8be2 docs: Fix typo in Step 3 of platformer tutorial (#2336)
The tutorial said to add a velocity variable and fill the update method in the EmberQuestGame class instead of the PlatformBlock class.
2023-02-12 15:01:26 +01:00
Hwanseok Barth Kang
7920e2ba4d fix: Use the hitboxParent instead of the parent in the componentTypeCheck (#2335)
* Fix benchmark file name to run as test

* QuadTree now uses a parentHitbox instead of parent

* Add tests

* Apply suggestions from code review

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* Replace the var name

* Revert mark as final

* Change default parameter name

---------

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
2023-02-11 10:45:59 +01:00
Pasha Stetsenko
5ceb5dda5c refactor: Component adoption now handled via ComponentTreeRoot (#2332)
Move commands are now stored inside the global queue of lifecycle events, and processed at each game tick before the start of the update() phase.
Component's LifecycleManager now completely removed.
2023-02-10 19:24:37 +00:00
Hwanseok Barth Kang
b5f79d1ce4 feat: Add DoubleTapCallbacks that receives double-tap events. (#2327)
As-is
As mentioned in #2321, the user needs to propagate double-tap events to the component tree using DoubleTapDetector & propagateToChildren until now.

To-be
Any components that are mixed into the DoubleTapCallbacks receive double-tap-related events.
Same as DragCallbacks, there is no need to add mixin to the game like HasDoubleTapCallbaks as before.
2023-02-10 19:29:36 +01:00
Hwanseok Barth Kang
0c14d4cb87 refactor: Divide TileLayer by its Layer type (#2326)
As-is

    The TileLayer became too big to maintain.
    Some tile related classes doesn't have factory method, their creation is done in other classes with big switch-case.

To-be

    Divided TileLayer into its Layer type. The Layer type is determined by MapOrientaion which has a member of isometric, orthogonal, staggered, and hexagonal.
    Instantiation is done by factory method inside the class.
2023-02-09 18:16:52 +00:00
Lukas Klingsbo
18ddc3b57d ci: Bump Melos in gh-pages (#2334) 2023-02-09 19:08:24 +01:00
Lukas Klingsbo
fb3c744e37 ci: Migrate to Melos 3 and Flutter 3.7.1 (#2330)
This PR migrates us to the prerelease version of Melos (3.0.0-dev.0) and our pipelines to Flutter 3.7.1

It's a golden opportunity for us to test the upcoming version of melos and give them any feedback that we might have. :)

The migration instructions can be read here:
https://melos.invertase.dev/guides/migrations
2023-02-08 22:49:05 +01:00
Pasha Stetsenko
754461850f refactor!: Use ComponentTreeRoot for component removal (#2317)
Component removal is now handled via the ComponentTreeRoot class and its queue of lifecycle events.

    The onGameResize event now only fires before the component's onMount, but not before its onLoad.

Migration instructions

If you have components that rely on receiving onGameResize calls before they load, then
you can retrieve the game's size in onLoad manually via findGame()!.size.
2023-02-08 13:54:40 +01:00
fpv999
5874f6007a fix: TextBoxComponent's boxConfig timePerChar generates "Optimized Out" error #2143 (#2328)
Error was happening because cachedImage.dispose(); was called multiple times on the same object.

#2143
2023-02-07 12:37:17 +01:00
Luan Nico
e0a4c07f2a docs: Update cspell github action and configuration (#2325)
I am on a crusade to improve our spellchecking. I have a big PR that I am now going to break down into very small chunks to for review.

zwaldowski's cspell-action has been deprecated in favor of streetsidesoftware/cspell-action.

This PR:

updates to use the new recommended cspell action
update to use checkout v3, because why not
fixes a few violations the new action caught
Note: I think we should make a distinction between things that should be in a dictionary (e.g. AABB, a standard industry acronym that we expect people to know what it is) and specific edge-cases/ignore rules for specific parts of specific files (e.g. something like fccc which is meaningless outside of the very specific context in which it is used). For the latter, I believe we should use case-by case exceptions.
2023-02-06 11:58:44 +01:00
Luan Nico
cc1957eb86 docs: Update broken fireslime references (#2324)
I am on a crusade to improve our spellchecking. I have a big PR that I am now going to break down into very small chunks to for review.

This is another hopefully not controversial one - broken links referencing the old Fire Slime.
Updating the links means we no longer need that word in our dictionary file.
2023-02-06 08:32:02 +01:00
Jochum van der Ploeg
8da21de37a chore: Clean up outdated code in flame_bloc (#2323)
Found another outdated section in our examples, fixed it up.
2023-02-05 20:32:50 +00:00
Hwanseok Barth Kang
34c3b6bdc4 feat: Add ability to opt-out flip (#2316)
As I mentioned on #2310 (comment),
it's inevitable to create an atlas that has 2x width from the original one to support flip, it could bring some limitations. So it would be great to opt out the flip.

Here's the reason why this is needed.
Flip may impact performance if the composed tileset(AKA texture) is big.
The software tiled has shortcuts to go back by cmd(ctrl)-z, rotating by z, and flipping horizontally by x. Imagine that you clicked a tile to the wrong place, you may press cmd-z and so on. In this situation, you can also accidentally press z or x, and as a result, the tile flips! It is fine with some complicated or flip(rotate)-consiousable tiles. But some things like the floor or sky are hard to recognize. I even made a program for my design team to pick out coordinates of where the flipped tiles exist but often there are flips. So, providing a way by simple boolean argument may prevent this.
2023-02-05 21:24:01 +01:00
Jochum van der Ploeg
90321658c4 docs: Fix old doc code (#2322)
Saw some old code references, fixed them up.
2023-02-05 16:31:16 +00:00
Pasha Stetsenko
3faf114994 feat!: HasDraggableComponents mixin is no longer needed (#2312)
This PR is first in a series of refactors that aim to simplify event handling in Flame. The approach is as follows:

    Added class GestureDetectorBuilder, which encapsulates the logic of applyGestureDetectors() in a class. This class resides within the Game and initiates widget rebuild whenever any new gesture detectors are added or removed. Note: 

    [idea] Convert HasTappableComponents/HasDraggableComponents into classes #1733 suggests having a list of interfaces inside the Game class -- this is essentially that list, encapsulated in a class.
    Added the MultiDragDispatcher component, which contains the logic that used to be within the HasDraggableComponents mixin. This component is internal; it mounts to a FlameGame directly, and ensures that it is a singleton.
    Whenever any DragCallbacks component is added to a game, it automatically adds the MultiDragDispatcher component (unless there is already one), which in turn registers a drag gesture detector with GestureDetectorBuilder and rebuilds the game widget.

The end result is that now in order to make a component draggable you only need to add the DragCallbacks mixin to that component, everything else will be handled by the framework.

Consequently, the HasDraggableComponents mixin is now empty and marked as deprecated.
2023-02-05 13:09:58 +00:00
Luan Nico
e2399f91e3 docs: Rename caveace asset to cave_ace in our examples (#2304)
I am on a crusade to improve our spellchecking. I have a big PR that I am now going to break down into very small chunks to for review.

Here I am renaming an asset to include a word separator, as the combined word "caveace" doesn't exist. This not only allows us to remove one unclear entry in our dictionary, but make our example code easier to read for new users.

Note: in order to easily update the internal name of the atlas (unrelated to file name), that is stored in the binary, I used this pending feature from Fire Atlas.
2023-02-04 23:42:38 +01:00
Pasha Stetsenko
6704753e07 test: Added test for accessing children in onMount (#2318)
Since we started using ComponentTreeRoot, the children of an unmounted component are stored in its children container -- which means the components added during onLoad are now accessible during onMount via children (even though they are still unmounted).

This PR adds a test for that.
2023-02-04 20:21:05 +01:00
Pasha Stetsenko
619b9b15da refactor: Added ComponentTreeRoot (#2300)
The ComponentTreeRoot is a special Component designed to sit at the root of a component tree. For example, FlameGame is a ComponentTreeRoot.
    The class contains a game-wide queue (RecycledQueue) for component lifecycle events. Currently this supports only Component.add functionality, but in the future we'll extend it to other functions as well: remove, re-parent, and re-balance.
    The new approach is supposed to be more efficient: instead of each component having their own queues of events, now there is just one central queue, which also supports recycling of elements, which means no unnecessary objects are created on every tick.
    The new approach should be more robust as well: previously, each component's queue was processed during that component's updateTree cycle -- now, all lifecycle events are resolved from one location, before the component tree is updated or rendered. If during the update phase the user schedules new components to be added/removed, then those changes will be always deferred to the next game tick. Thus, we have a guarantee that during a single game tick the structure of a component tree will remain constant.
        This is, of course, pending future refactoring to move the remaining lifecycle handling functionality into the ComponentTreeRoot.
2023-02-02 16:31:20 +01:00
Pasha Stetsenko
324392c24a style: Remove unused typedef in jenny's parser (#2313) 2023-02-02 09:52:20 +00:00
Pasha Stetsenko
914dc6a7cd fix: Camera no longer "sticks" to boundary with BoundedPositionBehavior (#2307)
Previously, when using BoundedPositionBehavior, the camera would "stick" to the world boundary as soon as the target moves outside. With this PR, the camera will now try to keep as close to the target as possible, even if it moves outside of the world boundary. Thus, the camera will now behave as if the boundary became "slippery".

Also added method nearestPoint() in class Shape.
2023-02-02 09:07:08 +01:00
avieville
e5345e62d0 RemoveATypoInTheCodeOfTuto (#2309)
Co-authored-by: avieville <github.avieville@gmail.com>
2023-01-30 14:31:26 -03:00
Luan Nico
343b84529d docs: Fix actual typos that made into our dictionary (#2305) 2023-01-28 16:58:27 -05:00
Anas
00b0dbef0d fix: Added useArtboardSize functionality (#2294) 2023-01-28 15:55:36 +01:00
Lukas Klingsbo
7662118d14 chore(release): Publish flame_lint 0.2.0 (#2301)
- flame_lint@0.2.0
2023-01-28 00:44:29 +00:00
Lukas Klingsbo
2b1f226618 fix: RouterComponent replace methods to correctly handle previous/nextRoute (#2296)
Before when you only had two routes you'd get:

Bad state: No element

dart:core                                                  List.last
package:flame/src/components/router_component.dart 260:30  RouterComponent._popWithoutMinimumAssert
package:flame/src/components/router_component.dart 122:7   RouterComponent.pushReplacementNamed
test/components/router_component_test.dart 20:14           main.<fn>.<fn>
2023-01-27 22:05:16 +00:00
Pasha Stetsenko
95b1fc0fbc feat: Added HardwareKeyboardDetector (#2257)
This creates a new component HardwareKeyboardDetector, which is a more advanced version of the KeyboardEvents mixin:

    HardwareKeyboardDetector is a component instead of a mixin, which means it can be added/removed by the user at any point;
    multiple such detectors can be attached to a game - for example, in a 2-player game one component may be paying attention to arrow keys, while another to WASD keys;
    the new component uses Flutter's HardwareKeyboard interface, bypassing the need for a Focus widget;
    the component keeps the ordered list of keys that are currently being pressed, which is helpful for games where this order is important;
    there is the ability to temporarily pause the reception of key events using keyEventsPaused property.
2023-01-27 21:57:42 +00:00