Flutter Flame using two Camera Components and hide a Component inside a World Component form one Camera

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

Flutter Flame using two Camera Components and hide a Component inside a World Component form one Camera

问题

在游戏中,使用了两个CameraComponents。一个相机用于实际的游戏玩法,而另一个用于向玩家显示小地图。这两个相机都利用了相同的World组件。目标是在小地图上显示一个特定坐标的目标,而不在第一个相机中可见。

唯一想到的方法是使用两个单独的世界。这是唯一的方法吗?不幸的是,您不能在CameraComponent前面隐藏一个组件。

英文:

In the game, two CameraComponents are employed. One camera is used for the actual gameplay, while the other serves the purpose of displaying a minimap to the player. Both cameras utilize the same World component. The objective is to display a target on the minimap at specific coordinates without it being visible in the first camera.

The only method that comes to mind is to have two separate worlds. Is that the only approach? Unfortunately, you cannot hide a component in front of a CameraComponent.

答案1

得分: 1

@override
void render(Canvas canvas) {
  if (CameraComponent.currentCamera == theCameraYouDontWantToRender) {
    return;
  }
  ...
  super.render(canvas);
}
英文:

You would have to override the render method of the component that you don't want to render and check which camera it is that is rendering it, so it would be something like this:

@override
void render(Canvas canvas) {
  if(CameraComponent.currentCamera == theCameraYouDontWantToRender) {
    return;
  }
  ...
  super.render(canvas);
}

huangapple
  • 本文由 发表于 2023年6月19日 03:36:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76502251.html
匿名

发表评论

匿名网友

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

确定