2011-03-02 75 views

回答

4

我假设你GameView有帆布,因为它绘制图形,对不对?在这种情况下,当你做你的绘图的其余部分,使用

//canvas.drawText(String text, float x, float y, Paint paint); this is the actual method 
canvas.drawText(score, 5, 5, null); //but yours would look more like this 

那么你就只需要创建的“分数”的字符串,并把它通过游戏进行更新。

此外,你可能想尝试addView(查看孩子)。它应该是这样的:

GameView.addView(TextView); 
2

有点无耻的自我宣传在这里,但如果你偷看Hexaddicus你会看到,我们分割画面到游戏视图和页脚是纯老视的东西。这我不是你要去的“外观”,但它是a的方式。如果你想要更内联的外观和感觉,那么显然你不应该走这条路。

只是不要尝试覆盖Android游戏视图的Android UI小部件。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/control_pane" 
    android:layout_width="fill_parent" 
    android:layout_height="48dip" 
    android:layout_alignParentBottom="true"> 
</FrameLayout> 
<com.sharpermindstech.android.hexaddicus.opengl.views.HexBoardView 
    android:id="@+id/gamefield" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_above="@id/control_pane" /> 
</RelativeLayout> 
相关问题