I can put the HTML and JavaScript together in the same .html
file, but the images need to be separate files. The only solution that comes to my mind is to give to the user a .zip
folder.
This is not pretty though... How else can I do this?
I can put the HTML and JavaScript together in the same This is not pretty though... How else can I do this? |
|||||
|
You can embed images in the HTML document using the dataurl-syntax which allows to put the base64 representation of the binary image data as the src-attribute of an image. This also works on any other kind of media file.
When you use CSS stylesheets, you can create these completely procedural in JavaScript. |
|||||
|
Just putting all the files into a .zip file isn't a viable solution because most web-applications need a web-server so that they can access resources via HTTP-requests. On some systems you can access files via the It might work for a very simple app where you have most resources inline but this really isn't the approach I'd recommend to anybody. There are alternatives though, such as: Build a native applicationYou can package your web-application as a native app using Node-Webkit. You can even use this to add native desktop features (such as local save-games) to your game. This isn't a "package and done" approach though.. you'll probably have to rewrite portions of your application and write different loaders (eg. with a desktop app you'll rather load the files via filesystem, whereas you use HTTP-Requests in a browser/online-game). Use HTML5 features to allow offline access of your appIf your primary goal is to allow the player to play your game offline, then you can also use application-cache to allow offline access of your app. This is a feature that works in most modern browsers. The added benefit is that the user doesn't have to download anything and can just use a bookmark to play your game even when offline. For resources that are being loaded asynchronously (AJAX) you'll also have to implement separate loading mechanisms. You could make use of local-storage to save these resources for offline use. |
|||||||||||||||||||||
|
For a Chrome-based solution to make the game run offline and enjoy some native functionality, you can consider making a Chrome App. This way, you can distribute it in Chrome Web Store for added visibility, you can enjoy some powerful APIs, and make it look more like a standalone app. The downside is, of course, requiring Chrome. |
|||
|