tom32i-asset-loader.js
Image, sprite, sound loader for HTML5 games.
Install:
npm install --save tom32i-asset-loader.js
Import
HTML:
ES6:
;
Node:
const AssetLoader = ;
Usage:
Asset
To load a single image
Arguments:
- source: (String) The url of the image
- callback: (Function) Callback called when the image is loaded
- load: (Boolean) Start loading imediately? (default false)
Example:
const Asset = AssetLoader;const image = 'jeff.jpg' { document;};
SpriteAsset
To load an image an split it into several images according to a grid
Arguments:
- source: (String) The url of the image
- callback: (Function) Callback called when the image is loaded and splited
- columns: number of columns in the grid
- rows: number of rows in the grid
- load: (Boolean) Start load imediately?
const SpriteAsset = AssetLoader;const sprite = 'jeff.jpg' 3 2 { sprite;};
Contribute
Clone the repository:
git clone git@github.com:Tom32i/asset-loader.js.git
Install dev dependencies:
npm install
Build dist:
npm run build