This Page is in development! The Loader Class is in development!
Currently, vas has one loader for images. Future vas versions will have more loading types available such as spritesheet loaders, as well as 3d model loaders. The loader class has a few bugs when attempting to draw images to the canvas. It will be used as followed:
//Usage for the loader class - Uses Vas.load Vas.load.image('img1', './icon.png'); // vas.load.image( key, src ); Vas.add.image('img1', 0, 0, 100, 100); // vas.add.image( key, dx, dy, sw, sh );
When an image is loaded, it takes in 2 parameters, a key and a src. The key allows the image to be referenced later, such as with vas.add.image();. The src is the source file.
While the loader seems to work on the testing page, trying to load images elsewhere seems to result in errors. i am trying to work on this so it loads without fail. I realized that I should load all images prior to drawing them, so I will be adjusting vas to do so.
The loader will support loading of many different file types, starting with basic image types (png, jpeg, jpg), but will later include .gif and spritesheet file loading! Then, when I implement Three.js support with Vas, I will add support for a few different 3D model formats.
WHAT IS IN DEVELOPMENT:
//Preloading to prevent image load error let vas = new Vas(); vas.gameArea.width = 512; vas.gameArea.height = 512 vas.gameArea.style = "border: 1px solid #333; box-shadow: 0 0 16px 2px rgba(0,0,0,1);" vas.preload.image('img1', './icon.png'); // vas.load.image( key, src ); vas.gameArea.start();