Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm making a simple 2d game in OpenGL ES and I want to add movement buttons to it. What's the best way of going about this? In previous projects I've simply added UIButtons to the view but I hear there are performance implications in doing so with OpenGL ES so I'm wondering what the possible alternatives are if so.

share|improve this question
I have been looking for multiple libraries and - as Piku suggests - have ended up drawing strips which are controlled with a few classes (buttons, sticks, pads...). – Coyote Jan 19 '12 at 14:28
up vote 6 down vote accepted

If you can detect the user tapping on the screen, and know how to draw a simple textured 'quad' (two textured triangles or a triangle strip/fan) then the simplest button is just a combination of the two.

Draw a quad on the screen, texture it with your button's image, then do a simple bounding box test to see if the user has tapped inside it.

Be careful researching about 'OpenGL GUIs' and the like, it can get horrifically complex very quickly. Write your game with the simplest thing that works rather than setting out to design your own GUI library.

share|improve this answer

I don't want to sound snarky, but have you actually profiled the performance of using a UIButton? Sometimes the simplest answer is the more appropriate. If the full on UIView is too much, maybe just using Core Graphics alone on a CAShapeLayer is good enough and would be less code. Don't just throw out all the stuff Apple gives you, leverage what's there when it makes sense.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.