flame-engine / flame Goto Github PK
View Code? Open in Web Editor NEWA Flutter based game engine.
Home Page: https://flame-engine.org
License: MIT License
A Flutter based game engine.
Home Page: https://flame-engine.org
License: MIT License
In my project with Dart2, when I use Flame.audio.play
, it prints following exception to the console.
[VERBOSE-2:dart_error.cc(16)] Unhandled exception:
type 'Future<dynamic>' is not a subtype of type 'Future<int>'
#0 AudioPlayer.play (package:audioplayers/audioplayer.dart:28:16)
#1 Audio.play (package:flame/audio.dart:47:37)
<asynchronous suspension>
Building my app 'nanny_mc', I see this error in CI/CD (using Codemagic):
== Install Flutter dependencies ==
Resolving dependencies...
Because every version of flutter_driver from sdk depends on convert 2.0.2 and every version of tiled depends on convert ^2.1.1, flutter_driver from sdk is incompatible with tiled.
And because flame >=0.10.0 depends on tiled ^0.2.0, flutter_driver from sdk is incompatible with flame >=0.10.0.
So, because nanny_mc depends on both flame 0.10.1 and flutter_driver any from sdk, version solving failed.
pub finished with exit code 1
In pubspec.yaml
, if I replace flame: 0.10.1
with flame 0.10.0
the build still fails. Alternatively, if I remove flame entirely as follows,
... the build succeeds.
Are you aware of this incompatibility between flame
and tiled
?
Adding flame >=0.10.3 to pubspec while using the stable channel results in following error.
Because app depends on flame >=0.2.0 <0.9.2 which requires SDK version >=1.8.0 <2.0.0 or >=2.0.0-dev.50.0 <2.0.0, version solving failed.
There should probably be a notice that using the latest version requires switching to master/dev channel.
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v1.4.10, on Mac OS X 10.14.4 18E226, locale pt-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2)
[✓] Android Studio (version 3.3)
[✓] VS Code (version 1.33.0)
[✓] Connected device (1 available)
After upgrading to version 0.10.3, animationAsWidget is not updating the animation. It was working in previous version.
@renancaraujo has fixed this, but with 0.10.3 release it is broken again.
I've created a StatelessWidget to show current Sprit:
class PokemonAnimation extends StatelessWidget {
final int number;
PokemonAnimation({Key key, @required this.number}) : super(key: key);
@override
Widget build(BuildContext context) {
return Flame.util.animationAsWidget(
Position(100.0, 100.0),
animation.Animation.sequenced('1-generation.png', 2,
textureX: PokemonPostision.fromNumber(number).imageX,
textureY: PokemonPostision.fromNumber(number).imageY,
textureHeight: PokemonPostision.height,
textureWidth: PokemonPostision.width,
stepTime: 0.2),
);
}
}
.. and the StatefullWidget:
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int poke;
void initState() {
super.initState();
poke = 1;
}
void plusPoke() {
setState(() {
poke++;
});
}
void minusPoke() {
setState(() {
var result = poke - 1;
if (result <= 0) result = 1;
poke = result;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text('Pokédex Fire Red/Leaf Green'),
centerTitle: true,
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
RaisedButton(
child: Icon(
Icons.navigate_before,
size: 20.0,
),
onPressed: minusPoke,
),
RaisedButton(
child: Icon(
Icons.navigate_next,
size: 20.0,
),
onPressed: plusPoke,
),
],
),
PokemonAnimation(number: poke),
Text('#$poke')
],
),
);
}
}
Source code is available here
Thanks !
This is a very useful override of the prepareCanvas method that I've been using:
// TODO pull up to flame! this is **very** useful
@override
void prepareCanvas(Canvas canvas) {
canvas.translate(x, y);
canvas.translate(width/2, height/2);
canvas.scale(inverted ? 1.0 : -1.0, 1.0);
canvas.translate(-width/2, -height/2);
}
This flips horizontally. PositionComponent should have a field to control that and allow for easy flipping of sprites, both horizontally and vertically (or both).
It would be a really good to have feature.
The audio_pool class is using deprecated methods from audioplayers:
Fix lib/audio_pool.dart. (-1.49 points)
Analysis of lib/audio_pool.dart reported 3 hints:
line 50 col 13: 'completionHandler' is deprecated and shouldn't be used.
line 60 col 16: 'completionHandler' is deprecated and shouldn't be used.
line 62 col 16: 'completionHandler' is deprecated and shouldn't be used.
We need to fix that ASAP to use the new stream APIs.
Add a method to verify if a gamepad is connected, this will be useful to for example show different tutorial for the player
Here is a starting point: https://developer.android.com/training/game-controllers/controller-input#input
I use AnimationComponent.sequenced
to make the animation sprite in my code, but it renders the whole images again and again(just flash in my screen), that is not what I wanted, the animation should be played with one frame and then another, here is the code:
this._createSwan().then((swan) => this.add(
this.swan = swan
..x = this.viewport.size.width / 2
..y = this.viewport.size.height / 3
));
Future<AnimationComponent> _createSwan() async{
await Flame.images.load("SwanSheet.png");
final size = 64.0;
return AnimationComponent.sequenced(size, size, "SwanSheet.png", 8, textureWidth: 2000.0, textureHeight: 250.0,);
}
The image is 2000 pixels width and 250 height, with 8 swan-sprite made. How to use the animation components? Help and thanks very much!
Create documentation on how to start a new game using Flame.
There could be two tutorials here
1- A classic game only application
2- Adding a game as a widget inside an existing Flutter app
Calls to Flame.audio.play() have a high performance impact.
I lose 5-15 frames making as few as two calls per second on a physical android s5.
The AudioPlayers lib now has a low latency API, this would be great for flame when playing sound effects.
We could implement an API here to take advantage of that.
Docs for the Text APIs is outdated, we must update it to the latest implementation
We should add more tutorials step-by-step on how to use the components of flame, focusing on people who never developed games and has chose Flame to start.
Tutorial example:
If anyone feels the need of other tutorials, just comment here on this issue
Hello. I'm really enjoying working with flame, and am actively building a game for a class of mine.
I was wondering if there was a way to "destroy" a Game
, in that I can successfully terminate a Game
after I've invoked .start()
?
I imagine something like myGame.stop();
for terminating the window rendering loop would be helpful for transitioning between Flutter widgets (for main screen handling / other Flutter stuff).
I would make a pull request, and might soon, but I'm not 100% sure how to avoid a constant assertion exception
E/flutter ( 9921): 'package:flutter/src/scheduler/binding.dart': Failed assertion: line 643 pos 12: '_schedulerPhase == SchedulerPhase.midFrameMicrotasks': is not true.
E/flutter ( 9921): #0 _AssertionError._doThrowNew (dart:core-patch/dart:core/errors_patch.dart:37)
E/flutter ( 9921): #1 _AssertionError._throwNew (dart:core-patch/dart:core/errors_patch.dart:33)
E/flutter ( 9921): #2 BindingBase&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:643:12)
E/flutter ( 9921): #3 _invoke (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:91)
E/flutter ( 9921): #4 _drawFrame (file:///b/build/slave/Linux_Engine/build/src/flutter/lib/ui/hooks.dart:80)
Suddenly this error occurs:
Compiler message: file:///Users/XXXX/.pub-cache/hosted/pub.dartlang.org/flame-0.10.3/lib/svg.dart:26:17: Error: Too few positional arguments: 3 required, 2 given. svgRoot.draw(canvas, null);
Reason is in file lib/src/vector_drawable.dart from flutter_svg
void draw(Canvas canvas, ColorFilter colorFilter);
was changed to
void draw(Canvas canvas, ColorFilter colorFilter, Rect bounds);
Add box2d docs and an example
In my game class, resize() gets called with size (0,0) in release / profile mode. In debug mode it provides correct size. Also sprites size on screen changes depending on mode.
Could be related to this:
flutter/flutter#14113
Merry Christmas Flame Fellows! 🎅 🎄🎄🎄🎄
Santa Claus is asking which features we'd like to have on Flame next year
Make your wish list here, and let's see what happens next :)) 🎁🎁🎁
Hi! Can you tell me, please, when you are planning to integrate support of dart v2.0 to engine? Is it have some problems?
When I make a simple game, I got the error again and again, how to solve it, thanks!
Another exception was thrown: type 'List<Comparable<dynamic>>' is not a subtype of type 'Iterable<Pair>' of 'iterable'
And the stack:
I/flutter (20726): When the exception was thrown, this was the stack:
I/flutter (20726): #0 List.setRange (dart:core/runtime/libarray.dart)
I/flutter (20726): #1 sort (package:box2d/src/buffer_utils.dart:151:8)
I/flutter (20726): #2 DefaultBroadPhaseBuffer.updatePairs (file:///D:/Software/Google/Flutter/SDK/flutter/.pub-cache/hosted/pub.flutter-io.cn/box2d-0.4.0/lib/src/collision/broadphase/default_broadphase_buffer.dart:140:17)
I/flutter (20726): #3 ContactManager.findNewContacts (file:///D:/Software/Google/Flutter/SDK/flutter/.pub-cache/hosted/pub.flutter-io.cn/box2d-0.4.0/lib/src/dynamics/contact_manager.dart:165:16)
I/flutter (20726): #4 World.stepDt (file:///D:/Software/Google/Flutter/SDK/flutter/.pub-cache/hosted/pub.flutter-io.cn/box2d-0.4.0/lib/src/dynamics/world.dart:566:23)
I/flutter (20726): #5 Box2DComponent.update (package:project_simple_game/flame/box2d/box2d_component.dart:39:11)
I/flutter (20726): #6 GameWorld.update (package:project_simple_game/game_world.dart:26:11)
I/flutter (20726): #7 GameRoot.update (package:project_simple_game/game_root.dart:33:21)
I/flutter (20726): #8 _GameRenderBox._update (package:project_simple_game/flame/game.dart:119:10)
I/flutter (20726): #9 _GameRenderBox._tick (package:project_simple_game/flame/game.dart:112:5)
I/flutter (20726): #10 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (20726): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:906:11)
I/flutter (20726): #12 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.forEach (dart:collection/runtime/libcompact_hash.dart:363:8)
I/flutter (20726): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:904:17)
I/flutter (20726): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:747:7)
I/flutter (20726): #16 _Timer._runTimers (dart:isolate/runtime/libtimer_impl.dart:382:19)
I/flutter (20726): #17 _Timer._handleMessage (dart:isolate/runtime/libtimer_impl.dart:416:5)
I/flutter (20726): #18 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
I/flutter (20726): (elided one frame from package dart:async)
I/flutter (20726):
I/flutter (20726):
I/flutter (20726): This exception was thrown in the context of a scheduler callback. When the scheduler callback was
I/flutter (20726): _registered_ (as opposed to when the exception was thrown), this was the stack:
I/flutter (20726): #0 new _FrameCallbackEntry.<anonymous closure> (package:flutter/src/scheduler/binding.dart:109:33)
I/flutter (20726): #1 new _FrameCallbackEntry (package:flutter/src/scheduler/binding.dart:112:6)
I/flutter (20726): #2 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleFrameCallback (package:flutter/src/scheduler/binding.dart:426:53)
I/flutter (20726): #3 _GameRenderBox._scheduleTick (package:project_simple_game/flame/game.dart:102:50)
I/flutter (20726): #4 _GameRenderBox._tick (package:project_simple_game/flame/game.dart:111:5)
I/flutter (20726): #5 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (20726): #6 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:906:11)
I/flutter (20726): #7 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.forEach (dart:collection/runtime/libcompact_hash.dart:363:8)
I/flutter (20726): #8 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:904:17)
I/flutter (20726): #9 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleBeginFrame (package:flutter/src/scheduler/binding.dart:834:5)
I/flutter (20726): #10 _invoke1 (dart:ui/hooks.dart:134:13)
I/flutter (20726): #11 _beginFrame (dart:ui/hooks.dart:105:3)
Hello,
I have been using Audio file from flame to play sounds.
Now, the issue I get is that the file sometimes get played and sometimes it doesnt.
I even tried to create one instance of AudioPlayer, to see if the issue is in multiple creation of AudioPlayer or async checking of cache. Same problem.
Every 0.5 Second I play one .wav
file, just a FX tick. Same error with .m4a
metronome.wav.zip
player.play(_audio.loadedFiles["metronome.m4a"].path, isLocal: true);
And on emulator first second and fourth tick stop working and later it works with ocasional skip.
On old android phone almost every second tick doesnt work.
When audio file gets skipped, I get no message in console, and when it does play I get
D/MediaPlayer(10220): setSubtitleAnchor in MediaPlayer
Can you point me in the direction where should I be looking for?
Thank you
Hi, i am begining developing simple game in flame. And i have no idea how to save game state in situation when application goes to background.
In current state, after moving back to foreground, is the game restarted.
Thank you for your reply and have a nice day
PS. Sorry for my English, my language skill is very poor :-)
Something like
Animation animation = ...
Animation reversed = animation.reversed(); // creates a new animation with the same frame but in reversed order
possible implementation:
return new Animation(frames.reversed.toList())
Something like this. Would be really useful.
Can't compile Flame on Android Studio 3.3.1
Android Studio 3.3.1
Build #AI-182.5107.16.33.5264788, built on January 28, 2019
JRE: 1.8.0_152-release-1248-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.15.0-45-generic
This error only occurs when Flame is added to the pubspec.yaml file of any project on my system. I've tried changing Flame version to no avail. I've tried using a hard coded version such as Flame: 0.10.1 with no effect. Removal of Flame from the pubspec.yaml file resolves the issue. However, it mean I can't build any projects that use flame. Which I really want to use! I would be very grateful for any help resolving this issue. Error info follow;
Compilation Error:
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Configure project :audioplayers
[Fatal Error] asm-util-5.1.pom:1:44: Content is not allowed in prolog.
[Fatal Error] asm-5.1.pom:1:44: Content is not allowed in prolog.
[Fatal Error] asm-commons-5.1.pom:1:44: Content is not allowed in prolog.
[Fatal Error] proguard-gradle-5.3.3.pom:1:44: Content is not allowed in prolog.
[Fatal Error] asm-analysis-5.1.pom:1:44: Content is not allowed in prolog.
[Fatal Error] asm-tree-5.1.pom:1:44: Content is not allowed in prolog.
[Fatal Error] guava-22.0.pom:1:44: Content is not allowed in prolog.
[Fatal Error] httpmime-4.1.pom:1:44: Content is not allowed in prolog.
[Fatal Error] httpclient-4.2.6.pom:1:44: Content is not allowed in prolog.
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
Could not resolve all artifacts for configuration ':audioplayers:classpath'.
Could not resolve org.ow2.asm:asm:5.1.
Required by:
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.lint:lint:26.0.1 > com.android.tools.lint:lint-checks:26.0.1 > com.android.tools.lint:lint-api:26.0.1Could not resolve org.ow2.asm:asm:5.1.
Could not parse POM https://jcenter.bintray.com/org/ow2/asm/asm/5.1/asm-5.1.pom
Content is not allowed in prolog.
Could not resolve org.ow2.asm:asm-analysis:5.1.
Required by:
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.lint:lint:26.0.1 > com.android.tools.lint:lint-checks:26.0.1
Could not resolve org.ow2.asm:asm-analysis:5.1.
Could not parse POM https://jcenter.bintray.com/org/ow2/asm/asm-analysis/5.1/asm-analysis-5.1.pom
Content is not allowed in prolog.
Could not resolve org.ow2.asm:asm-commons:5.1.
Required by:
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1
Could not resolve org.ow2.asm:asm-commons:5.1.
Could not parse POM https://jcenter.bintray.com/org/ow2/asm/asm-commons/5.1/asm-commons-5.1.pom
Content is not allowed in prolog.
Could not resolve org.ow2.asm:asm-util:5.1.
Required by:
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1
Could not resolve org.ow2.asm:asm-util:5.1.
Could not parse POM https://jcenter.bintray.com/org/ow2/asm/asm-util/5.1/asm-util-5.1.pom
Content is not allowed in prolog.
Could not resolve net.sf.proguard:proguard-gradle:5.3.3.
Required by:
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1
Could not resolve net.sf.proguard:proguard-gradle:5.3.3.
Could not parse POM https://jcenter.bintray.com/net/sf/proguard/proguard-gradle/5.3.3/proguard-gradle-5.3.3.pom
Content is not allowed in prolog.
Could not resolve org.ow2.asm:asm-tree:5.1.
Required by:
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.lint:lint:26.0.1 > com.android.tools.lint:lint-checks:26.0.1 > com.android.tools.lint:lint-api:26.0.1
Could not resolve org.ow2.asm:asm-tree:5.1.
Could not parse POM https://jcenter.bintray.com/org/ow2/asm/asm-tree/5.1/asm-tree-5.1.pom
Content is not allowed in prolog.
Could not resolve com.google.guava:guava:22.0.
Required by:
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:gradle-api:3.0.1
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.databinding:compilerCommon:3.0.1
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1 > com.android.tools:common:26.0.1
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1 > com.android.tools.analytics-library:shared:26.0.1
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1 > com.android.tools.analytics-library:tracker:26.0.1
Could not resolve com.google.guava:guava:22.0.
Could not parse POM https://jcenter.bintray.com/com/google/guava/guava/22.0/guava-22.0.pom
Content is not allowed in prolog.
Could not resolve org.apache.httpcomponents:httpclient:4.2.6.
Required by:
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1 > com.android.tools:sdklib:26.0.1
Could not resolve org.apache.httpcomponents:httpclient:4.2.6.
Could not parse POM https://jcenter.bintray.com/org/apache/httpcomponents/httpclient/4.2.6/httpclient-4.2.6.pom
Content is not allowed in prolog.
Could not resolve org.apache.httpcomponents:httpmime:4.1.
Required by:
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1 > com.android.tools:sdklib:26.0.1
Could not resolve org.apache.httpcomponents:httpmime:4.1.
Could not parse POM https://jcenter.bintray.com/org/apache/httpcomponents/httpmime/4.1/httpmime-4.1.pom
Content is not allowed in prolog.
Could not resolve com.google.guava:guava:22.0.
Required by:
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.build:builder:3.0.1 > com.android.tools:sdklib:26.0.1 > com.android.tools:repository:26.0.1 > com.google.jimfs:jimfs:1.1
Could not resolve com.google.guava:guava:22.0.
Could not parse POM https://jcenter.bintray.com/com/google/guava/guava/22.0/guava-22.0.pom
Content is not allowed in prolog.
Could not resolve com.google.guava:guava:22.0.
Required by:
project :audioplayers > com.android.tools.build:gradle:3.0.1 > com.android.tools.build:gradle-core:3.0.1 > com.android.tools.lint:lint:26.0.1 > com.android.tools.lint:lint-checks:26.0.1 > com.android.tools.lint:lint-api:26.0.1 > com.android.tools.external.lombok:lombok-ast:0.2.3
Could not resolve com.google.guava:guava:22.0.
Could not parse POM https://jcenter.bintray.com/com/google/guava/guava/22.0/guava-22.0.pom
Content is not allowed in prolog.
BUILD FAILED in 1s
Command: /home//AndroidStudioProjects/barn_stormer_2/android/gradlew app:properties
Finished with error: Please review your Gradle project setup in the android/ folder.
When I make the little game, I am confused with the different coordinates in the widgets or components:
Flame.util.initialDimensions()
?Box2dComponents
when specifys the BodyDef
in _createBody
? Actually it is a Vector2
value:final bodyDef = new BodyDef();
bodyDef.position = new Vector2(0.0, -24.0);
BodyComponent
? Use the body.position
in components?Thanks very much for helping!
To have the best game experience it might be needed to do additional configuration.
One example for that would be drawing over the notch area in android (fix here).
It would be nice to have a collection of those configurations available in the documentation or in the readme.
There are a couple of things that requires doing because of #50. These are important things to fix, so I'm adding here for us not to forget!
This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: BaseGame.components, BaseGame._addLater, BaseGame.size, BaseGame.camera, BaseGame._dts
Other stuff added by the user will give the same problem. So, we need to find a way to fix this ASAP.
I use the dependencies: flame: ^0.9.0
, but I cannot import the component
library, what I can import is the line below:
import 'package:flame/components/';
//import 'package:flame/component.dart'; this line doesn't work
This line is useless... What I miss?
Aseprite exports its animations in spritesheet format, along side the image, it can also export a json with the information from that animation, I think it would be a great feature for Flame with we add some support for that, since Aseprite is one of most used 2d pixel art tools out there, here is an example of the json:
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 16, "h": 32 },
"sourceSize": { "w": 16, "h": 32 },
"duration": 100
},
"reset-bot 2.ase": {
"frame": { "x": 32, "y": 0, "w": 16, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 16, "h": 32 },
"sourceSize": { "w": 16, "h": 32 },
"duration": 100
},
"reset-bot 3.ase": {
"frame": { "x": 48, "y": 0, "w": 16, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 16, "h": 32 },
"sourceSize": { "w": 16, "h": 32 },
"duration": 100
},
"reset-bot 4.ase": {
"frame": { "x": 64, "y": 0, "w": 16, "h": 32 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 16, "h": 32 },
"sourceSize": { "w": 16, "h": 32 },
"duration": 2000
}
},
"meta": {
"app": "http://www.aseprite.org/",
"version": "1.2.9",
"image": "/Users/erick/projetos/gamedev/test-spritesheet/reset-bot.png",
"format": "RGBA8888",
"size": { "w": 80, "h": 32 },
"scale": "1",
"frameTags": [
{ "name": "booting", "from": 0, "to": 4, "direction": "forward" }
],
"layers": [
{ "name": "Layer 1", "opacity": 255, "blendMode": "normal" },
{ "name": "Layer", "opacity": 255, "blendMode": "normal" }
],
"slices": [
]
}
}
My suggestion for an API for this would be something like:
Animation.fromAsepriteData(imagePath, dataPath)
What do you think @luanpotter and @feroult ?
The docs state to create a new instance of ParallaxComponent, which results in an dart(new_with_abstract_class)
error.
https://github.com/luanpotter/flame/blob/master/doc/components.md
Abstract classes have to be extended like
class MyParallaxBG extends ParallaxComponent {
}
Hi @luanpotter,
First of all thanks for making this tool, looks amazing and just what I need.
I'm having an issue when I add Flame as a dependency.
This is how my pubspec.yaml looks like:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.0
cloud_firestore: ^0.0.3
firebase_auth: ^0.3.1
flame: ^0.6.2
I run flutter packages get
which exits with 0.
Then I run flutter run
and I get the output below:
Launching lib/main.dart on iPhone X in debug mode...
Error detected in pubspec.yaml:
#/properties/flutter: type: wanted [object] got null
Running pod install... 2.8s
CocoaPods' output:
↳
Preparing
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods-Runner`: (`arm64`)
Finding Podfile changes
A audioplayers
A path_provider
M cloud_firestore
- Flutter
- firebase_auth
Fetching external sources
-> Fetching podspec for `Flutter` from `/Users/andreu/flutter/bin/cache/artifacts/engine/ios`
-> Fetching podspec for `audioplayers` from `/Users/andreu/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.3.0/ios`
-> Fetching podspec for `cloud_firestore` from `/Users/andreu/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.0.4/ios`
-> Fetching podspec for `firebase_auth` from `/Users/andreu/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.3.1/ios`
-> Fetching podspec for `path_provider` from `/Users/andreu/.pub-cache/hosted/pub.dartlang.org/path_provider-0.2.1+1/ios`
Resolving dependencies of `Podfile`
Comparing resolved specification to the sandbox manifest
A audioplayers
A path_provider
- BoringSSL
- Firebase
- FirebaseAnalytics
- FirebaseAuth
- FirebaseCore
- FirebaseDatabase
- FirebaseFirestore
- FirebaseInstanceID
- Flutter
- GTMSessionFetcher
- GoogleToolboxForMac
- Protobuf
- cloud_firestore
- firebase_auth
- gRPC
- gRPC-Core
- gRPC-ProtoRPC
- gRPC-RxLibrary
- leveldb-library
- nanopb
Downloading dependencies
-> Using BoringSSL (9.0)
-> Using Firebase (4.5.0)
-> Using FirebaseAnalytics (4.0.4)
-> Using FirebaseAuth (4.3.1)
-> Using FirebaseCore (4.0.10)
-> Using FirebaseDatabase (4.1.0)
-> Using FirebaseFirestore (0.9.1)
-> Using FirebaseInstanceID (2.0.5)
-> Using Flutter (1.0.0)
-> Using GTMSessionFetcher (1.1.12)
-> Using GoogleToolboxForMac (2.1.3)
-> Using Protobuf (3.4.0)
-> Installing audioplayers (0.0.1)
-> Using cloud_firestore (0.0.1)
-> Using firebase_auth (0.0.1)
-> Using gRPC (1.6.5)
-> Using gRPC-Core (1.6.5)
-> Using gRPC-ProtoRPC (1.6.5)
-> Using gRPC-RxLibrary (1.6.5)
-> Using leveldb-library (1.20)
-> Using nanopb (0.3.8)
-> Installing path_provider (0.0.1)
- Running pre install hooks
[!] Pods written in Swift can only be integrated as frameworks; add `use_frameworks!` to your Podfile or target to opt into using it. The Swift Pod being used is: audioplayers
/usr/local/Cellar/cocoapods/1.3.1/libexec/gems/cocoapods-1.3.1/lib/cocoapods/installer/xcode/target_validator.rb:115:in `block (2 levels) in verify_framework_usage'
/usr/local/Cellar/cocoapods/1.3.1/libexec/gems/cocoapods-1.3.1/lib/cocoapods/installer/xcode/target_validator.rb:110:in `each'
/usr/local/Cellar/cocoapods/1.3.1/libexec/gems/cocoapods-1.3.1/lib/cocoapods/installer/xcode/target_validator.rb:110:in `block in verify_framework_usage'
/usr/local/Cellar/cocoapods/1.3.1/libexec/gems/cocoapods-1.3.1/lib/cocoapods/installer/xcode/target_validator.rb:107:in `each'
/usr/local/Cellar/cocoapods/1.3.1/libexec/gems/cocoapods-1.3.1/lib/cocoapods/installer/xcode/target_validator.rb:107:in `verify_framework_usage'
/usr/local/Cellar/cocoapods/1.3.1/libexec/gems/cocoapods-1.3.1/lib/cocoapods/installer/xcode/target_validator.rb:38:in `validate!'
/usr/local/Cellar/cocoapods/1.3.1/libexec/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:405:in `validate_targets'
/usr/local/Cellar/cocoapods/1.3.1/libexec/gems/cocoapods-1.3.1/lib/cocoapods/installer.rb:118:in `install!'
/usr/local/Cellar/cocoapods/1.3.1/libexec/gems/cocoapods-1.3.1/lib/cocoapods/command/install.rb:41:in `run'
/usr/local/Cellar/cocoapods/1.3.1/libexec/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/usr/local/Cellar/cocoapods/1.3.1/libexec/gems/cocoapods-1.3.1/lib/cocoapods/command.rb:52:in `run'
/usr/local/Cellar/cocoapods/1.3.1/libexec/gems/cocoapods-1.3.1/bin/pod:55:in `<top (required)>'
/usr/local/Cellar/cocoapods/1.3.1/libexec/bin/pod:23:in `load'
/usr/local/Cellar/cocoapods/1.3.1/libexec/bin/pod:23:in `<main>'
Error output from CocoaPods:
↳
[!] Automatically assigning platform ios with version 8.0 on target Runner because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
Error running pod install
Error launching application on iPhone X.
flutter --version
gives me this output:
Flutter • channel master • https://github.com/flutter/flutter.git
Framework • revision 3914214641 (3 weeks ago) • 2017-11-01 22:31:29 -0700
Engine • revision 88cf09ffe6
Tools • Dart 1.25.0-dev.11.0
Am I missing anything?
Hi,
The code Flame.util.addGestureRecognizer(createTapRecognizer());
throws the following error:
[VERBOSE-2:shell.cc(184)] Dart Error: Unhandled exception:
NoSuchMethodError: The getter 'pointerRouter' was called on null.
Receiver: null
Tried calling: pointerRouter
#0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
#1 Util.addGestureRecognizer (package:flame/util.dart:55:29)
#2 new MatchingGame (package:myapp/main.dart:24:16)
#3 main (package:myapp/main.dart:12:27)
#4 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:289:19)
#5 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)
Error -32601 received from application: Method not found
The code example:
class MGame extends BaseGame {
MGame() {
Flame.util.addGestureRecognizer(createTapRecognizer());
}
TapGestureRecognizer createTapRecognizer() {
return new TapGestureRecognizer()
..onTapUp =
(TapUpDetails details) => this.handleTap(details.globalPosition);
}
handleTap(Offset details) {
// TODO:....
}
}
Am I doing something wrong?
I'm not sure if I'm doing something wrong, but whenever I place a widget created with Flame.util.animationAsWidget in a moving Widget such as a GridView or ListView, the animations are in the completely wrong position. For example, the skeleton sprite should be within the green container, but it is not at all. There is no problem with placing the animationAsWidgets in rows or columns, only when in moving components.
Trying to render a white path where the User has inputs via his touch drag controller. It works fine using Flame addGestureRecognizer method, but unfortunately the add() method renders the PathSprites on a one time screen. For example, if I open the window containing the GameScreen, the path the user drags his fingers is shown, but once I close it and reopen it the screen (creating another instance of GameScreen), the path is no longer shown.
There are other renders within the Screen and they all work fine the 2nd, 3rd, 4th... time, but this breaks after the 1st time it works.
`
void _initializeDragController() {
PanGestureRecognizer gestureDetector = new PanGestureRecognizer( );
Flame.util.addGestureRecognizer(
gestureDetector
..onUpdate = (startDetails) => dragInput(startDetails.globalPosition));
Flame.util.addGestureRecognizer(gestureDetector
..onEnd = (DragEndDetails d) => onUp());
}
void dragInput(Offset position) {
touchPositionDx = position.dx;
touchPositionDy = position.dy;
var newSprite = new PathSprite( touchPositionDx, touchPositionDy );
_checkSize(); // checks so see if path.length > 30 and removes the first entry
path.add(newSprite);
add( newSprite );
}
PathSprite( this.xpostion, this.ypostion ) : super.square( PathSprite.baseSize, 'path.png' );
@override
bool destroy() {
return toDestroy;
}
@override
void resize(Size size) {
this.x = PathSprite.baseSize * xpostion;
this.y = PathSprite.baseSize * ypostion;
this.maxY = size.height;
}
`
Everything else is working fine, the Dx and Dy positions are correct and updated in real time on all screens, but again, the render works only once for the Path Sprites.
Create docs for the Tiled support
Hi, today I had some time to test your engine an I really appreciate the effort, but I ran into a problem.
If I use the old version 6.2 I can easily draw sprites, but with version 8.1 nothing happens.
I tried all documentation hints and tutorials I could find.
Code:
import 'dart:ui';
import 'package:flame/palette.dart';
import 'package:flame/components/text_box_component.dart';
import 'package:flame/text_config.dart';
TextConfig regular = TextConfig(color: BasicPalette.white.color);
TextConfig tiny = regular.withFontSize(12.0);
class HelpView extends TextBoxComponent {
HelpView(String text)
: super(text,
config: tiny, boxConfig: const TextBoxConfig(timePerChar: 0.05));
@override
void drawBackground(Canvas c) {
final Rect rect = Rect.fromLTWH(0, 0, width, height);
c.drawRect(rect, Paint()..color = const Color(0xFFFF00FF));
c.drawRect(
rect.deflate(boxConfig.margin),
Paint()
..color = BasicPalette.black.color
..style = PaintingStyle.stroke);
}
}
Error:
pub.dartlang.org/flame-0.10.2/lib/components/text_box_component.dart:140:36: Error: A value of type 'Future
' can't be assigned to a variable of type 'Image'.
- 'Future' is from 'dart:async'.
- 'Image' is from 'dart:ui'.
Try changing the type of the left hand side, or casting the right hand side to 'Image'.
return recorder.endRecording().toImage(width.toInt(), height.toInt());
^
Compiler failed on D:\OneDrive\dev\galaxygame\lib\main.dart
Finished with error: Gradle task assembleDebug failed with exit code 1
Disclaimer: Flame is one of my first attempts at game development overall, just because I love flutter.
I know this isn't a issue and more a stackoverflow question, but being the case that the docs and the examples does not show how to do that you might want take the issue to add a documentation action.
I'm currently trying to implement a flappy bird with Flame, but it's being really hard to do basic stuff, mostly because of lack of documentation.
I already have the player jumping around, the HUD is working, but the way I currently have the background to move continuously feels hacky, and that is probably something a lot of people would like to have in 2D games, a tile background.
Currently I had to overlap 2 components of my background and when they hit the beginning of the screen x=0 I'm repositioning them to the end of the screen x=width.
Having to have 2 backgrounds seems odd, and doesn't feel natural on game development, same thing is happening to the ground where the bird can 'hit'.
Can we pleeeease have an example or documentation on how to tile an endless background?
Thanks.
I'm making a game contains a sound effect that plays frequently.
After playing for a while, first the sounds missing, and then app crash, ios crash.
The first method I use is
Flame.audio.play('xxx.mp3');
On Android it works perfectly, but ios will crash after playing a while.
After some researching, according to this.
I try AudioPool
as well, but another problem came.
It works perfectly on Android as it always does, but it can't play on IOS, not a single sound.
At last I made my own method, it works for me.
I do something like this.
Class MyAudio{
static int playIndex=0;
static List<AudioPlayer> playerList = [AudioPlayer(),AudioPlayer(),AudioPlayer()];
static AudioPlayer get getPlayer{
playIndex = playIndex < playerList.length - 1 ? playIndex + 1 : 0;
return playerList[playIndex];
}
static init() async{
playerList.forEach((au){
au.setUrl((await Flame.audio.load('xxx.mp3')).path, isLocal: true);
au.setVolumn(.8);
});
}
}
main() async{
await MyAudio.init();
...
}
And play it by using
MyAudio.getPlayer.resume();
The first and the second method I have used, I'm wondering if I it's the version problem,
by the way my enviroment is:
$ flutter --version
Flutter 1.2.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 8661d8aecd (6 weeks ago) • 2019-02-14 19:19:53 -0800
Engine • revision 3757390fa4
Tools • Dart 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
and I use version 0.10.2
of Flame.
I tried upgrade Flutter to branch master
to use 0.10.3 Flame
, but Flutter seems to become out of my control, errors occur, after I get rid of the errors, my Flame.audio.play('xxx.mp3');
and AudioPool
issue remain the same, I gave up and reinstall Flutter to user the stable
branch.
This is all I been through, hope it can help someone.
Create docs for the ComposedComponent class
We should lock the flutter version on Flame's pubspec to avoid people trying Flame on unsupported Flutter version.
Create docs and example for debug features, like fps, debug_component and etc
I tested 3000px x 4000px 1MB png x 100 files in /assets/images.
and
void main() async {
....
await Flame.images.loadAll(list);
}
40 images loaded but over 50 failed out of memory. (3g ram device)
android:largeHeap="true" didn't help.
Do you have any solutions?
(actually i need 1MB x 500 images..)
So, because xxx depends on both flame ^0.10.3 and path_provider ^0.5.0, version solving failed.
pub get failed (1)
I have a SpriteComponent
that will be substituted by an AnimationComponent
during the game. I've been thinking to compose this logic into a single PositionComponent
that controls whether I render SpriteComponent
or AnimationComponent
, to improve semantics.
Looking into that, how about Component
class have an OrderedSet
of subcomponents just like BaseGame
? I this way, methods like render
and update
would be synchronized.
I shall open a pull request in the near future with some ideas in this regard.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.