英文:
Flutter Flame parallax not showing images on ios device
问题
这是我的代码,在安卓设备上完美运行,但在iOS设备上不显示,只是黑屏。
class MyParallaxComponent extends ParallaxComponent<RocketMan> {
@override
Future<void> onLoad() async {
parallax = await gameRef.loadParallax([
ParallaxImageData('rocket_bg/sky_color.png'),
ParallaxImageData('rocket_bg/farground_cloud_1.png'),
ParallaxImageData('rocket_bg/farground_cloud_2.png'),
ParallaxImageData('rocket_bg/farground_mountains.png'),
ParallaxImageData('rocket_bg/midground_mountains.png'),
ParallaxImageData('rocket_bg/foreground_mountains.png'),
],
baseVelocity: Vector2(5, 0),
velocityMultiplierDelta: Vector2(1.8, 1.0),
fill: LayerFill.width);
}
}
当然,我将它添加到游戏的 onLoad()
中:add(MyParallaxComponent());
。
如果我将 fill
更改为 LayerFill.height
,它会在屏幕上显示,但图像会显示得很大,不符合原计划。
提前感谢任何建议!
英文:
here's my code and it works perfectly on Android, but doesn't show on ios devices, just black blank screen.
class MyParallaxComponent extends ParallaxComponent<RocketMan> {
@override
Future<void> onLoad() async {
parallax = await gameRef.loadParallax([
ParallaxImageData('rocket_bg/sky_color.png'),
ParallaxImageData('rocket_bg/farground_cloud_1.png'),
ParallaxImageData('rocket_bg/farground_cloud_2.png'),
ParallaxImageData('rocket_bg/farground_mountains.png'),
ParallaxImageData('rocket_bg/midground_mountains.png'),
ParallaxImageData('rocket_bg/foreground_mountains.png'),
],
baseVelocity: Vector2(5, 0),
velocityMultiplierDelta: Vector2(1.8, 1.0),
fill: LayerFill.width);
}
and of course i add it in the game's onLoad(): add(MyParallaxComponent());.
It does show on the screen if I change the fill to LayerFill.height, but the images display huge and not as it's planned.
Thanks in advance for any suggestions!
答案1
得分: 1
这是 Impeller 中的一个错误,如果您关闭 Impeller,它将正常工作。
您可以尝试使用以下示例:
flutter run --no-enable-impeller
编辑:在 Flutter 3.13 中已修复。
英文:
This is a bug in Impeller, if you turn off Impeller it will work.
You can try this with for example:
flutter run --no-enable-impeller
EDIT: This is fixed in Flutter 3.13
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论