Flutter Flame视差在iOS设备上不显示图像。

huangapple go评论65阅读模式
英文:

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&lt;RocketMan&gt; {
  @override
  Future&lt;void&gt; onLoad() async {
    parallax = await gameRef.loadParallax([
      ParallaxImageData(&#39;rocket_bg/sky_color.png&#39;),
      ParallaxImageData(&#39;rocket_bg/farground_cloud_1.png&#39;),
      ParallaxImageData(&#39;rocket_bg/farground_cloud_2.png&#39;),
      ParallaxImageData(&#39;rocket_bg/farground_mountains.png&#39;),
      ParallaxImageData(&#39;rocket_bg/midground_mountains.png&#39;),
      ParallaxImageData(&#39;rocket_bg/foreground_mountains.png&#39;),
    ],
        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

huangapple
  • 本文由 发表于 2023年7月10日 11:30:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76650536.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定