You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe it's not a bug, but it's pretty weird, so my Player class requires a picture, and I'm sure I've loaded that before creating the player class but that's not working at all and warns
`he following assertion was thrown building FutureBuilder(dirty, state:
_FutureBuilderState#19a16):
Tried to access an image "characters/amiy/idle.png" that does not exist in the cache. Make
sure to
load() an image before accessing it
'package:flame/src/cache/images.dart':
Failed assertion: line 104 pos 7: 'asset != null'
The relevant error-causing widget was:
FutureBuilder
FutureBuilder:file:///home/huan_moon/.pub-cache/hosted/pub.flutter-io.cn/flame-1.17.0/lib/s
rc/game/game_widget/game_widget.dart:389:30
@override
Color backgroundColor() {
return const Color(0xff5fcde4);
}
@override
FutureOr<void> onLoad() async {
print('Amiy\'s Island is loading...');
images.loadAllImages();
world = Island();
camera = CameraComponent.withFixedResolution(width: 600, height: 600);
camera.viewfinder.anchor = Anchor.topLeft;
add(Player(camera));
print('test2');
return super.onLoad();
}
}```
my player class
class Player extends SpriteAnimationGroupComponent with KeyboardHandler, HasGameRef {
CameraComponent camera;
double velocity = 1.0;
late final SpriteAnimation idleAnimation;
What happened?
Maybe it's not a bug, but it's pretty weird, so my Player class requires a picture, and I'm sure I've loaded that before creating the player class but that's not working at all and warns
`he following assertion was thrown building FutureBuilder(dirty, state:
_FutureBuilderState#19a16):
Tried to access an image "characters/amiy/idle.png" that does not exist in the cache. Make
sure to
load() an image before accessing it
'package:flame/src/cache/images.dart':
Failed assertion: line 104 pos 7: 'asset != null'
The relevant error-causing widget was:
FutureBuilder
FutureBuilder:file:///home/huan_moon/.pub-cache/hosted/pub.flutter-io.cn/flame-1.17.0/lib/s
rc/game/game_widget/game_widget.dart:389:30
When the exception was thrown, this was the stack:
#2 Images.fromCache (package:flame/src/cache/images.dart:104:7)
#3 Player.onLoad (package:amiys_island/entities/player.dart:36:28)
#4 Component._startLoading (package:flame/src/components/core/component.dart:856:26)
#5 Component._addChild (package:flame/src/components/core/component.dart:606:20)
#6 Component.add (package:flame/src/components/core/component.dart:568:46)
#7 AmiysIsland.onLoad (package:amiys_island/amiys_island.dart:25:9)
#8 Game._onLoadFuture (package:flame/src/game/game.dart:71:45)
#9 Game._onLoadFuture (package:flame/src/game/game.dart)
#10 Game.load (package:flame/src/game/game.dart:83:12)
#11 FlameGame.load (package:flame/src/game/flame_game.dart:105:17)
#12 GameWidgetState.loaderFuture.
(package:flame/src/game/game_widget/game_widget.dart:194:20)
#13 GameWidgetState.loaderFuture
(package:flame/src/game/game_widget/game_widget.dart:199:9)
#14 GameWidgetState.build...
(package:flame/src/game/game_widget/game_widget.dart:390:33)
#15 GameWidgetState._protectedBuild
(package:flame/src/game/game_widget/game_widget.dart:228:21)
#16 GameWidgetState.build..
(package:flame/src/game/game_widget/game_widget.dart:376:28)
#17 _LayoutBuilderElement._layout.layoutCallback
(package:flutter/src/widgets/layout_builder.dart:139:77)
#18 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2844:19)
#19 _LayoutBuilderElement._layout
(package:flutter/src/widgets/layout_builder.dart:173:12)
#20 RenderObject.invokeLayoutCallback.
(package:flutter/src/rendering/object.dart:2686:59)
#21 PipelineOwner._enableMutationsToDirtySubtrees
(package:flutter/src/rendering/object.dart:1097:15)
#22 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:2686:14)
#23 RenderConstrainedLayoutBuilder.rebuildIfNecessary
(package:flutter/src/widgets/layout_builder.dart:248:7)
#24 _RenderLayoutBuilder.performLayout
(package:flutter/src/widgets/layout_builder.dart:331:5)
#25 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7)
#26 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11)
#27 RenderProxyBoxMixin.performLayout
(package:flutter/src/rendering/proxy_box.dart:105:21)
#28 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7)
#29 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11)
#30 RenderProxyBoxMixin.performLayout
(package:flutter/src/rendering/proxy_box.dart:105:21)
#31 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7)
#32 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11)
#33 RenderProxyBoxMixin.performLayout
(package:flutter/src/rendering/proxy_box.dart:105:21)
#34 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7)
#35 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11)
#36 RenderProxyBoxMixin.performLayout
(package:flutter/src/rendering/proxy_box.dart:105:21)
#37 RenderObject.layout (package:flutter/src/rendering/object.dart:2575:7)
#38 RenderBox.layout (package:flutter/src/rendering/box.dart:2389:11)
#39 RenderView.performLayout (package:flutter/src/rendering/view.dart:195:14)
#40 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2414:7)
#41 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1051:18)
#42 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1064:15)
#43 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:582:23)
#44 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:991:13)
#45 RendererBinding._handlePersistentFrameCallback
(package:flutter/src/rendering/binding.dart:448:5)
#46 SchedulerBinding._invokeFrameCallback
(package:flutter/src/scheduler/binding.dart:1386:15)
#47 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1311:9)
#48 SchedulerBinding.scheduleWarmUpFrame.
(package:flutter/src/scheduler/binding.dart:1034:7)
#52 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
(elided 5 frames from class _AssertionError, class _Timer, and dart:async-patch)`
and this is my code
class Player extends SpriteAnimationGroupComponent with KeyboardHandler, HasGameRef {
CameraComponent camera;
double velocity = 1.0;
late final SpriteAnimation idleAnimation;
}```
help is appreciated
The text was updated successfully, but these errors were encountered: