【Ogre Overlay 文本水平居中实现方式】

// The name of the overlay comes first
overlay MyOverlays/ANewOverlay
{
    zorder 200
 
    overlay_element MyOverlayElements/TestPanel Panel
    {
   		 metrics_mode relative
        // Center it horizontally, put it at the top
        left 0.25
        top 0
        width 0.5
        height 0.1
        // Another panel nested in this one
        overlay_element MyOverlayElements/AnotherPanel TextArea
        {
        	 metrics_mode relative
             left 0
             top 0
             width 0.1
             height 0.1
             horz_align center//水平对齐
			font_name Ogre
   			 char_height 0.08
   			 caption 100
        }
    }
      overlay_element MyOverlayElements/AnotherPanel TextArea
        {
       		  metrics_mode relative
             left 0
             top 0
             width 0.1
             height 0.1
			font_name Ogre
			char_height 0.04
             caption km
        }
}
OverlayManager::getSingleton().getOverlayElement("MyOverlayElements/AnotherPanel").setAlignment(TextAreaOverlayElement::Center);//设置文本居中

显示效果:
100 km
0 km
55 km

你可能感兴趣的:(学习)