想要在游戏的主视图中显示时间吗?
我目前正在为 Android 开发一个简单的游戏,其中主要操作发生在我的 GameView 类上,它只是 View 的扩展。
我想在 GameView 的左上角添加一些显示时间的文本,并且想知道实现此目的的最佳方法?
我使用下面的代码来显示
public void onTick(long millisUntilFinished) { TIME=(int) (millisUntilFinished/1000);
timeCanvas.drawText("time= "+TIME, 30, 30, timePaint);
invalidate();
}
但无法正常显示。它覆盖每个计数增量。 还有其他方法可以显示时间吗?
我还使用了文本视图。但无法在此自定义 viewGive 解决方案或任何要显示的示例代码中将 TIME 设置为文本......
I am currently developing a simple game for Android where the main action occurs on my class GameView, which is simply an extension of View.
I want to add some text showing the time in the top left corner of my GameView, and would like to know the best way of implementing this?
I used foolowing code to display
public void onTick(long millisUntilFinished)
{
TIME=(int) (millisUntilFinished/1000);
timeCanvas.drawText("time= "+TIME, 30, 30, timePaint);
invalidate();
}
But it cannot display properly. Its override every count increment.
Is there any other method to display time?
Also i used text view. but couldnt set TIME as text in this customized viewGive solution or any sample code to display....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这篇文章可以帮助您
}
};
开始
停止
This article help you
}
};
to start
to stop