英文:
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);
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论