javascript clock demo

General discussion about Box2D tutorials
Post Reply
headwinds
Posts: 11
Joined: Sat Dec 29, 2012 8:14 pm

javascript clock demo

Post by headwinds »

first impression...the clock is incredible! but in fact it may just be too awesome... too complex for a getting started demo. One of the other samples like the bike on the landscape might be more appropriate; aiming more at indie game developers.

I'd also like to be able to see\toggle the skins like you can in the bike demo.

and why not also include a link to download the javascript source?! No need to hide the unminified versions in the html ;)

<!-- Un-minified versions of the above
<script type="text/javascript" src="box2dweb.js"></script>
<script type="text/javascript" src="loadrube.js"></script>
<script type="text/javascript" src="testbed.js"></script>
-->

When you export the json from the editor, it might also be nice to autogenerate the loadrube.js file too and drop it in the same directory. When I first looked at the exported json I thought "Great! now how am I going to parse this sucker...?!" but obviously that's already taken care of within loadrube.js.
headwinds
Posts: 11
Joined: Sat Dec 29, 2012 8:14 pm

Re: javascript clock demo

Post by headwinds »

just reading over the loadrube.js and testbed.js files...

on line 412, it mentions:

//the RUBE scenes are loaded via jQuery post, so the draw() call above usually
//does not catch them. Call this at the end of the post function.
function doAfterLoading() {

can you point me to the file that actually loads the external clock json file?
headwinds
Posts: 11
Joined: Sat Dec 29, 2012 8:14 pm

Re: javascript clock demo

Post by headwinds »

right, ok I see - it kicks off within clocktest.js :D which loads the json file and then each of the other demos, have their own similar files.
headwinds
Posts: 11
Joined: Sat Dec 29, 2012 8:14 pm

Re: javascript clock demo

Post by headwinds »

I did a little bit of work to create a version of the demo with unminified source and made it easier to download so that any javascript dev can load it on their local host; hunt through it and learn how it was assembled...

demo
source

..basically helped me answer my own questions and might save the next js dev a couple hours
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: javascript clock demo

Post by iforce2d »

The original source is included in the trial version download. I figure smart people like yourself will look at the html in the demo page to see what's going on, but it has to be commented there to avoid messing up the page.

The actual loading of the scene is done in the createWorld() function in the testbed.js file (specifially by the eval call). Yes, this just kicks off the loading process. When the response from the server is received, each individual test may have some specific work to do in its own js file. The loading of images is a common procedure, so this is done by the doAfterLoad() function in testrube.js again. A little roundabout I have to admit :)

The trial download also includes a 'standalone' version of this which does not use jQuery and can run from disk (file://) without a webserver. Some browsers may prevent images from loading with this method though, especially Chrome. See this and this.
headwinds
Posts: 11
Joined: Sat Dec 29, 2012 8:14 pm

Re: javascript clock demo

Post by headwinds »

Because of that image loading issue, I would always run a local server with Mamp - when you're developing for the web, it's best to simulate it as much as possible

I tried the trial first and liked it so much - really wanted to start exporting json - that I jumped to purchase and I guess I missed your stand alone version - I'll take a look... and yes a version without a local server would even easier to get started :-D
Post Reply