new ParallaxLayer(pos, size, parallax, renderOrder, drawFunction, canvasSize)parallax.js:33Create a parallax layer and draw its image
posVector2 optionalWhere the middle of the image is in the world when the camera is there too
sizeVector2 optionalWorld size of one copy of the image
parallaxnumber|Vector2 optional, default 0.5How much of the camera's movement it follows, 0 stays with the world and 1 with the screen, a Vector2 to follow x and y by different amounts
renderOrdernumber optionalLow to draw behind the game, far layers lowest
drawFunctionfunction optionalDraws the image, given the canvas context, its size in pixels and the layer; mountains when not given; called once when the layer is made and on redraw(), not each frame, so it draws with the canvas 2D context, not the engine's draws like drawTile
canvasSizeVector2 optionalSize of the image in pixels
// three ranges of mountains, the far ones lighter and slower
for (let i = 3; i--;)
new ParallaxLayer(vec2(0, i*2), vec2(40, 20), .9 - i*.2, -1e3 + i,
parallaxMountains(hsl(.6, .3, .7 - i*.2), hsl(.6, .5, .2), i));
// or draw your own image into the layer
new ParallaxLayer(vec2(), vec2(40, 20), .5, -1e3, (context, size)=>
{
context.fillStyle = '#fff';
context.fillRect(size.x/2 - 20, size.y/2 - 20, 40, 40);
});