我目前正在为Android开发一个简单的游戏,其中主要操作发生在我的类GameView上,这只是View的扩展.
我想在GameView的左上角添加一些显示分数的文字,想知道实现这个的最佳方法吗?
提前致谢
马特德鲁里
我假设你的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
Run Code Online (Sandbox Code Playgroud)
然后你只需要创建"得分"字符串并让它由游戏更新.
此外,您可能想尝试addView(View child).它看起来像这样:
GameView.addView(TextView);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
484 次 |
| 最近记录: |