Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
191
rated 0 times [  194] [ 3]  / answers: 1 / hits: 17105  / 13 Years ago, fri, december 23, 2011, 12:00:00

Most of us know that HTML5 Canvas element is having much better support with these amazingly fast Javascript Engines from Firefox, Safari and Chrome.



So recently I have been experimenting with game development with Javascript and the Canvas, and I am wondering what would be a good approach to be creating a Start Screen for a Javascript Game.



So far, the only idea I have would be creating a UI before the game and stuff with Javascript and use Event Listeners to track the mouse and when they click buttons. But I'm not sure if this a wise thing to do.



What would a good way to go about a Starting Screen, etc. in a Javascript game? Any help would be useful, thanks!



UPDATE: Thanks for the blazing fast reply(s)! A lot of you are suggesting placing a img until the game loads, etc. So do I need to write a asset manager or some sort - to check when all the images etc. are loaded?


More From » jquery

 Answers
28

Populate a div tag with your splash screen. Have it showing on page load and have your canvas hidden. Add a 'start' button to the div tag and on it's click event, hide the splash screen div tag and show the canvas using either jQuery or classic JavaScript.



Here is some sample code using jQuery:



   <div id=SplashScreen>
<h1>Game Title</h1>
<input id=StartButton type=button value=Start/>
</div>

<canvas id=GameCanvas style=display: none;>Game Stuff</canvas>

<script>
$(#StartButton).click(function () {
$(#SplashScreen).hide();
$(#GameCanvas).show();
});
</script>

[#88400] Thursday, December 22, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
micayla

Total Points: 148
Total Questions: 92
Total Answers: 109

Location: Aruba
Member since Sat, Oct 2, 2021
3 Years ago
micayla questions
Fri, Dec 24, 21, 00:00, 2 Years ago
Thu, Apr 16, 20, 00:00, 4 Years ago
Thu, Nov 14, 19, 00:00, 5 Years ago
;