Html5 Base-App

Posted by (twitter: @Nehmulos)
December 9th, 2012 10:37 am

This weekend I created the base that I’m going to use for the next Ludum Dare.
It uses cocos2d-javascript for graphics, box2d.js for physics and a custom Audiomanager.

If you want to get started with cocos2d-javascript, a look on my source code might be useful for you, since the tutorials are outdated.

I have a custom PhysicsNode class that provides a simple constructor for box2d shapes and synchronizes a cocos2d graphics node with the box2d.body.

Preloading images
I modified cocos2d-javascript to allow simple resource preloading from javascript.
Earlier versions required you to use the cocos2d commandline tool that merged all your files.
Now you can just write this in your Application.js file:

registerResource("images/myimage.png", "image/png");

The custom Audiomanager first checks which codecs are supported,
when you give it an audio file to preload it will use the first url for a supported format:

    "ogg": "audio/blub.ogg",
    "aac": "audio/conversions/blub.aac"

Then you can play it with using the given alias"blub");

The repository also contains a small bash script that converts all ogg files in the audio directory into aac and wav files using ffmepg.

Please feel free to use this base for your own games.
It’s licensed under the zlib license, which means: do WTF you want, just don’t claim, that you wrote code that was written by others.

You can test it here.

Tags: , , , , ,

Leave a Reply

You must be logged in to post a comment.

[cache: storing page]