Heyo,
i have been trying to look for a possibility to implement SafeArea (or something equal to that) in my flame game. I found this (https://github.com/ikbendewilliam/flutter_flame_architecture/blob/main/lib/src/widgets/flame_safe_area.dart) but I dont know how to fully implement this in the screen leading to the game
Is there a simple solution for this issue I am missing?
Since the GameWidget that you wrap your FlameGame in is just a normal Flutter widget you can put the GameWidget as a child of a SafeArea.
Related
I am looking for way to implement wraparound widget in flutter. I need to create screen which space will be finite but unbounded, In other words I want to do something like when widget1 leaves the side of the screen it have to reappear on the opposite side immediately. I have stack and thanks to positioned I am re-rendering new position of widget based on accelerometer.
I don't know where to even start looking, if there is some package for it or should I implement it from scratch?
Please have a look at the package carousel_slider
https://pub.dev/packages/carousel_slider
It also features infinity scrolling which should provide the effect you want.
Above the image to below the animation.
How to Extract the single part of the image element in flutter then make to below animation.
How to achieve this type of animation in flutter. It was done by CSS. I was working to make this type of animation but I need some Suggestions and Example. If you know please share your experience and knowledge for achieve this.
You must have the SVG file of each of the gears and use the Rotation Transition Widget and stack Widget for Rotation and use AnimatedContainer for wieght
Can Flutter Flame render Widget inside game world like other components? (not overlay widget).
(I want to apply forge2d physic to widget and I'm trying to do it with Flame.)
You can not, you can only do it through the overlay system or use a Stack, but the widgets are never "in" the game, but on top of the game.
The game can only have Flame Components added directly to it.
You can still interact with the overlay widgets from the game though, like this for example: https://twitter.com/spydon/status/1417832832693673988
In that example I simply wrap the ElevatedButton with Positioned and Transform and then I updated those with the values from corresponding BodyComponents.
I need a listView for my Game. Is there a simple way to create one? There are no tutorials for such a feature and I couldn't find anything in the documentation.
Flame doesn't provide their own widgets for these things, we rely on Flutters excellent widget system.
So you create the widget directly in Flutter and then you either put your GameWidget in a stack (or similar) and use Flutter's own Navigation to move between the widgets, or you use Flame's overlay system.
For using the overlays you add the overlays that you want to have accessible when you create the GameWidget and then you call game.overlays.add to render a specific widget, and game.overlays.remove to stop rendering it.
Basically I'm trying to build a game to learn flutter more.
Right now I'm just trying to get a Text widget to move from the top of the phone screen, towards the bottom of the phone screen... I'm building a Space Invaders type of game with just Text.
From what I've read by googling the problem, should I use Flame? Or can everything be done by just using the base Flutter framework (collision detection, moving widgets, etc...)? Thanks.
You can use Draggable class for dragging the item.
A simple way to solve this problem is to have the moving Text widget a child of the Stack() widget. Actually, the child of the Stack() widget is a Positioned() widget, which has left and top properties, which you can update periodically with a Timer.periodic function to move the widget down by incrementing top property. So, your Text widget is a child of the Positioned() widget, that you use for, well, positioning.
I have a working example of this in my slowly_moving_widgets_field project, where I have a bunch of arbitrary widgets moving about the screen every X seconds as you desire.