Tuesday, August 4, 2015

android - How are buttons made to be clicked?


I just want to ask a general question. According to that answer, I'll continue thinking.


You know in games there are lots of clickable items. Play button, exit, combo-boxes, etc.


My question is: Are those buttons drawn in same canvas with background and all other things, or for every different thing there is another canvas object?


My question is a general sense. I'm not asking about a specific game, I'm asking how they are made generally.


I'm planning to start a game on Android, and I'm confused actually how to design buttons, and other object. Probably I'm going to use View/SurfaceView for now. I don't have much experience with OpenGL yet.


Thanks in advance.



Answer



If you are going to use the Android APIs (such as Canvas) for graphics and insist on not starting with OpenGL yet (a wise choice for a beginning programmer), you are only going to have one canvas object with multiple images drawn using drawBitmap(). In onTouchEvent() determine if the touch was inside the bounds of your object and, if so, call the necessary method. Good luck!


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...