如何在LibGDX中创建Minimap?

问题描述:

我正在根据不同的房间创建迷你地图。我完成了所有与显示世界上正确房间相关的代码。如何在LibGDX中创建Minimap?

现在它只是不同位置的精灵ArrayList。

它看起来像这样:

enter image description here

我面临着一些问题。

第一:

我不知道如何把它变成框架。

二:

我想滚动它并将其移动手指触摸。

我想它应该是一些演员团体。

我看着Group类和所有它的继承者,它看起来不像有演员可以解决我的问题。

如果你想使用演员,你需要有一个图像来显示纹理区域它不适用于雪碧。一个弹出和隐藏的对话框和一个ScrollPane来启用小地图的滚动。

Dialog dialog = new Dialog("", skin); 
Table widget = new Table(skin); 

// GameObject is a generic class use your project values 
for (GameObject gameObject : gameObjects){ 
    // you'll need to check if the position is relative to the parent or it's relative to 
    // the screen otherwise use the cell.setActorX() cell.setActorY() 
    Image image = new Image(gameObject.textureRegion); 
    image.setX(gameObject.x); 
    image.setY(gameObject.y); 

    widget.addActor(image); 
} 

ScrollPane scrollPane = new ScrollPane(widget); 
scrollPane.setScrollingDisabled(false, false); 

dialog.add(scrollPane).width(width).height(height); 

要显示和隐藏对话框设置此更新方法/点击侦听器。

dialog.show(stage); 
dialog.hide();