206 Commits

Author SHA1 Message Date
ff3d91075c feat: Adding filterQuality arguments to Parallax load methods (#2596)
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.
2023-06-30 06:03:00 +02:00
b3efb612cb feat: ComponentKey API (#2566)
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.
2023-06-20 09:36:15 -03:00
2d45d2be39 chore: Remove 1.8.0 deprecations (#2538)
Removes all the deprecated methods before 1.8.0 release.
2023-05-22 19:01:55 +02:00
b41622db8f fix: Solve warnings from 3.10.0 analyzer (#2532)
Just solves the warnings that the new Flutter version complains about (which makes us lose 10 points on pub).
2023-05-14 16:25:23 +02:00
5d1a6fd167 feat: Spine bridge package (#2530)
This PR introduces a bridge package for Spine.

https://user-images.githubusercontent.com/744771/236058480-75c8212b-98e6-4e3b-834a-c1a9d4de31a8.mp4
2023-05-05 23:17:15 +02:00
472356df31 docs: WeldJoint docs and example (#2525)
WeldJoint docs and example
2023-05-01 20:22:28 +02:00
0991c3bf67 docs: RopeJoint documentation and example (#2520)
RopeJoint documentation and example
2023-04-25 10:37:31 +02:00
1ed2c5a297 feat: Add stepEngine to Game (#2516)
This PR adds a new method to Game which allows advancing the game loop by a certain amount of time while the engine is paused. By default it assumes one frame to be ~16 ms, but it can be controlled while calling stepEngine

The idea is to allow easy frame by frame inspection of the game. It can even be added to FlameStudio as part of the start/pause buttons on the toolbar.

https://user-images.githubusercontent.com/33748002/233453501-b9f90d49-1834-4f0f-9536-77629cfcadbc.mp4
2023-04-23 21:28:37 +02:00
a25b0a03a5 feat: Customise grid of NineTileBox (#2495)
The previous implementation of the NineTileBox calculates identically sized tiles in a 3x3 grid and does not allow the user to customise this. For example, a 60x60 pixel sprite will be cut into 20x20 pixel tiles. This MR allows the user to specify the sizes of the fixed-width and fixed-height rows and columns so that a completely custom grid is possible.

Example with the following sprite and custom grid sizes.
Note that the stretchable row and column are only 1 pixel wide/high in this example.
2023-04-19 08:04:09 +00:00
87b8a067f3 refactor!: Move CameraComponent and events out of experimental (#2505)
This moves the CameraComponent and the new event system out of experimental since this now is the recommended way of handling things.
2023-04-19 09:55:32 +02:00
89926227c5 feat: Accept CollisionType in hitbox constructor (#2509)
With this PR we accept the `CollisionType` directly in the constructor.
2023-04-18 13:57:16 +00:00
dbda37b81a refactor: Add new lint rules (#2477)
This PR adds the following lint rules to our list:

```
always_put_required_named_parameters_first
avoid_multiple_declarations_per_line
avoid_positional_boolean_parameters
avoid_returning_null_for_void
avoid_returning_this
avoid_unnecessary_containers
enable_null_safety
library_private_types_in_public_api
no_leading_underscores_for_library_prefixes
no_leading_underscores_for_local_identifiers
prefer_null_aware_method_calls
tighten_type_of_initializing_formals
unnecessary_late
use_setters_to_change_properties
```

And these rules were considered, and some changes were made according to
them as a clean-up, but in many places they didn't make sense
(`prefer_asserts_with_message` I would have included, but there were too
many places that needed to be changes):

```
collection_methods_unrelated_type
prefer_asserts_with_message
avoid_renaming_method_parameters
```
2023-04-13 19:42:00 +00:00
78b585fe8e docs: Added GearJoint docs and example (#2487)
GearJoint docs and example
2023-04-13 21:09:26 +02:00
47372087f2 feat!: Update AudioPlayers to ^4.0.0 (#2482)
This updates flame_audio to use the recently released audioplayers 4.0.0

Migration instructions:

AudioPool has moved to AudioPlayers, but we still export it from
flame_audio, so the only thing you have to do if you import AudioPool
directly is to change the import to:
import 'package:flame_audio/flame_audio.dart';
2023-04-11 21:51:43 +02:00
bd3e788612 feat: Deprecate Component.changeParent (#2478)
Since we now have a setter directly for parent, changeParent is no longer needed.
2023-04-11 16:55:27 +02:00
e4f741ef23 docs: PrismaticJoint docs and example (#2470)
PrismaticJoint example and documentation
2023-04-07 12:17:05 +00:00
de630a1c3a feat: Add isDragged in DragCallbacks mixin (#2472)
Adding a isDragged state for DragCallbacks mixin. This was available in the Draggable mixin.
2023-04-07 13:39:28 +02:00
b5bdf4ec17 feat!: The HasTappableComponents mixin is no longer needed (#2450)
This PR is the second in a series of refactors that aim to simplify event handling in Flame. The approach is as follows:

    Added the MultiTapDispatcher component, which contains the logic that used to be within the HasTappableComponents mixin. This component is internal; it mounts to a FlameGame directly, and ensures that it is a singleton.
    Whenever any TapCallbacks component is added to a game, it automatically adds the MultiTapDispatcher component (unless there is already one), which in turn registers a tap gesture detector with GestureDetectorBuilder and rebuilds the game widget.

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

Consequently, the HasTappableComponents mixin is now empty and marked as deprecated.
2023-04-02 16:52:57 +00:00
b83c50737c docs: Added RevoluteJoint documentation (#2451)
Added RevoluteJoint documentation section
Moved the related example to the joints subfolder, and renamed the second example to avoid confusion.
2023-03-31 21:23:31 +02:00
a3f1601db8 feat: Adding ImageExtension.resize (#2418)
Adds a helper method to ImageExtension to make it easier to resize an image.
2023-03-31 11:39:08 +00:00
83c718fd50 docs: Update source code urls of forge2d joints in Flame Examples (#2437)
Update source code urls of forge2d joints in Flame Examples
2023-03-29 15:55:52 +00:00
d2a8fe01fa feat: Add HasTimeScale mixin (#2431)
This PR adds a new mixin on Component. When attached to a component, it allows scaling the delta time of that component as well as all its children by a non-negative factor. The idea is to allows slowing down or speeding up the gameplay by change the scaling factor.

Note: This approach works only for framerate independent game logic. Code in update() that is not dependent on delta time will remain unaffected by time scale.
2023-03-27 22:01:42 +02:00
e1049470fa docs: PulleyJoint documentation and example (#2425)
PulleyJoint documentation and example
2023-03-24 16:50:34 +01:00
277bd5d55c docs: MouseJoint documentation (#2417)
MouseJoint documentation, mostly copied from box2d docs. Moved the
existing example to joints subfolder
2023-03-18 15:21:30 +01:00
637c258b25 feat: Change HasCollisionDetection to be on Component (#2404)
This change makes it possible to have the collision detection system further down in the tree than on the FlameGame, this enables you to have collision detection on the World component for example.
Today it doesn't work if you have several worlds where the components are overlapping across the worlds, since the hitboxes live on top level.

So now you can use a World like this:

class CollisionDetectionWorld extends World with HasCollisionDetection {}
and all hitboxes added in there will only react with other hitboxes added to that world.
2023-03-15 13:11:23 +01:00
b2fdf06a79 feat: Introduce flame_noise, deprecate NoiseEffectController (#2393)
This:

* Deprecates the NoiseEffectController that is based on the deprecated
vector_math library impl
* Adds a new bridge package `flame_noise` to bridge fast noise

Note: the *goal* of this PR is to allow the immediate deprecation of the
old NoiseEffectController by providing an experimental, suitable
replacement. I believe the package flame_noise will look nothing like
this at all if I am able to land [some improvements to the underlying
fast_noise lib](https://github.com/frankpepermans/fast_noise/pull/5). We
will be able to have for example a generic NoiseEffectController.

However I believe we should merge this as an experimental package for
now to unblock removing the current implementation from Flame which is
negatively affecting our scores on pub. Therefore I would advise we
don't spend any time discussing specifics of how the API/impl provided
for the flame_noise, and just go with _something_ instead of nothing.
2023-03-14 20:59:21 -04:00
cb52f5a58a docs: MotorJoint doc and example (#2394)
Documentation covering MotorJoint and a usage example.
2023-03-12 22:31:20 +00:00
0ea612d73a docs: FrictionJoint documentation and example (#2383)
Added documentation and example for FrictionJoint.
Also modified main.dart to be able to run individual examples by providing page param.
2023-03-06 23:34:45 +01:00
4f5e56f05f feat: Added AlignComponent layout component (#2350)
This PR adds first layout component: AlignComponent, an equivalent of Align widget in Flutter.

AlignComponent sizes itself to its parent, and then keeps its child aligned to the specified anchor within its own bounding box.

Also adding onParentResize() lifecycle method, which is similar to onGameResize, but fires whenever the parent of the current component changes its size for any reason. (FlameGame is assumed to have the size canvasSize, and will invoke onParentResize whenever the canvas size changes).

Additional layout components are planned to be added in future PRs.
2023-03-02 22:51:02 +01:00
5b07bd58f3 docs: DistanceJoint documentation and example (#2369)
DistanceJoint documentation and example
2023-02-27 22:29:07 +01:00
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
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
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
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
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
f4b0e73fa1 feat: Added computed property CameraComponent.visibleWorldRect (#2267)
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.
2023-01-13 14:20:30 +00:00
d898b539f7 refactor!: The method onLoad() now returns FutureOr<void> (#2228)
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.
2022-12-23 20:30:40 +00:00
bd7f51f5b6 feat: Adding ComponentNotifier API (#1889)
This adds a proposal for a new API for flame, the ComponentNotifier.

This API offers the user change notifiers classes that are tied to FlameGame and its components so the user can be notified when a component is added, removed or updated.

This will enable users to:

    Take the benefit of reactive programming inside the game
    Have a simple way of watching certain states from the game, on Flutter Widgets

One important note here is that this proposal does not mean to replace integrations like flame_bloc, but rather provider an simple and out of the box solution, without any need of additional packages, since change notifiers are provided by flutter itself.

Opening this as draft for now to get feedback on the implementation, will write tests and docs once we have the final implementation.
2022-11-26 13:44:12 +00:00
51a896b2c8 feat: clampLength for Vector2 extension (#2190)
With this method you can clamp the length of a vector, instead fitting it in a box like clamp and clampScalar does.
2022-11-25 14:36:18 +00:00
3a73d1456c feat: Lottie bridge package (#2157)
This PR adds support for Lottie animations to flame
2022-11-22 21:42:15 +00:00
93dc432547 fix!: Correct coordinate system for a circular viewport (#2174) 2022-11-20 19:11:47 +01:00
9870eadaad docs: Fix bad links in docs as well as minor updates (#2170)
Closes: #2169

As discussed, a quick fix to some bad links and while I was in Flame Isolate, fixed some bad grammar.
2022-11-16 16:11:36 +01:00
cbfa789e75 chore: Fix some spelling mistakes (#2148)
Fix all* typos reported by CSpell, and add some more words into the dictionaries.

(Except for two in the flame_isolate/example package).
2022-11-06 14:06:44 +00:00
4bf9563013 chore: Fix some spelling errors (#2146) 2022-11-05 12:17:48 +01:00
b25b935644 feat: FlameIsolate - a neat way of handling threads (#1909)
Adding a bridge library for integral_isolates adding support for components to run CPU intensive code with a function similar to Flutter's compute function, but with a long lived isolate. Lifecycle is handled by the game loop, where the isolate would live between onMount and onRemove.
2022-10-31 21:06:27 +01:00
03751a2f54 docs: SpriteAnimation benchmark example (#2131) 2022-10-29 13:49:03 -04:00
bcecd3c1bd feat: Added glow effect using maskFilter (#2129) 2022-10-29 17:44:15 +01:00
9e6bf4fbcc feat: Add paint layers to HasPaint and associated component renders (#2073) 2022-10-24 22:37:24 +00:00
bc43838c92 docs: Add performance test game to examples (#2117) 2022-10-24 22:57:46 +02:00
6fe517a0c2 ci: Added Spell checker in CI (#2006)
Added spell check in Github CI
2022-10-22 16:51:00 +02:00