开发者

Edit box for my game?

I am creating an Android game. Currently I'm using a "normal" View and draw, the onDraw() and have a Handler to process timed events and such. However Soon (tm) I will convert it to a SurfaceView with a Thread and a constant loop.

Anyway, when the player presses a certain button, I want to have a kind of edit box for the player to enter a value (a price). But I'm kind of lost on how to achieve this. First I thought, ok let's just make an EditText, position it on the screen, and done. But apparently I can't just put an EditText on an X,Y location and remove it afterwards.

I looked at the LunarLander example, which uses a TextView for displaying text. It is already defined in the layout XML and is turned visible and invisible by sending messages between the game thread and the UI thread. This seems awefully complicated and the edit box would exist all the time.

Furthermore I was thinking on making my own "edit box" by simply drawing a box on the screen, enabling the keyboard, and then capturing input from the keyboard. But I wouldn't even know where to begin with "custom" keyboard input (on screen vs physical, how to capt开发者_开发知识库ure keyboard text input, how to hide the keyboard again when done, etc).

So I was wondering, what's the best way to do this?

Edit: maybe useful to know, but my game is fixed in landscape mode.


How about popping up a dialog box with some fancy graphics with the EditText in it?

If you want to stick to using only the SurfaceView, then you may have to implement your own simple GUI system. I'd look around, maybe there're some GUI libs out there for android games.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜