how to add background to kaboom js
async function init() { kaboom(); let bgImage = await loadSprite("background", "https://www.paulwheeler.us/files/windows-95-desktop-background.jpg"); let background = add([ sprite("background"), // Make the background centered on the screen pos(width() / 2, height() / 2), origin("center"), // Allow the background to be scaled scale(1), // Keep the background position fixed even when the camera moves fixed() ]); // Scale the background to cover the screen background.scaleTo(Math.max( width() / bgImage.tex.width, height() / bgImage.tex.height )); } init();
Source: stackoverflow.com