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 have coded my main menu for the game in html/css and need the image buttons to function with the engine using JavaScript.
For example:

Skip (Enable) Which skips the menu when you come back to play to continued the game.

(Disable ) Which will return it normal where you can see menu again

Skip – one image button red off and when click turns green on

Restart - Which when clicked opens a box with two images in it and text. (image + Yes, image + NO) if you click YES it restarts game and when you click NO resumes game.

Sound - will have one image button which will be red (Default ON) and when click turns green sound turns Off.

Example: function ENGINE_get_option_state(opt:string):string { return…; }


share|improve this question

You bind the images/buttons to a variable, then you can access that from your javascript.

For example:

<img id="startGame" src="image.png" />

Here's how you access the image from javascript:

var startGame = document.getElementById('startGame');

Now that you have the element in a variable you can do what you want with it. Just setup a function that executes the code you want the button to do. The function can look something like this:

startGame.onclick = function() {
alert('Game started!'); // Execute code here.

Very basic, hope this helps.

EDIT: Paste the following to a html document, and you have something to experiment with.

#startGame {width:100px; height:50px; background:black;}
<div id="startGame"></div>
window.onload = function() {
    var startGame = document.getElementById('startGame');

    startGame.onclick = function() {
        alert('Game started!');
share|improve this answer
Thanks for the reply and also this html/css menu is for an app game for both Android and ISO (iphone, ipad, and itouch). When you click play it plays the game on the phone its installed on. – akamerc Jul 14 '12 at 7:52
Shouldn't matter since javascript is a browser technology not a phone specific language. Even though browsers render things differently this code is so basic it should work in all of them. – justanotherhobbyist Jul 14 '12 at 8:37
Well first of all I'm not getting paid by this company and yes its a project and the reason I'm asking for help is because I'm knew at this and want to learn – akamerc Jul 15 '12 at 11:21
Do you know a website where I can read on this to learn the coding. Also, sorry for any misunderstanding here. – akamerc Jul 15 '12 at 11:22 and are both free websites offering good online courses. Try them out and go with the one you like the best. – justanotherhobbyist Jul 15 '12 at 11:28

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.