https://codepen.io/BambiTP/pen/OPVrQWm
//creates pixi canvas and app
async function initPixi(){
app = new PIXI.Application();
await app.init({ width: 1280, height:800 });
document.body.appendChild(app.canvas);
};
//caches textures for drawing
function cacheFrame(id,Col,Row) {
const url ='https://static.koalabeast.com/textures/classic/tiles.png';
const img = new Image();
img.crossOrigin = 'anonymous';
img.src = url;
img.onload = () => {
const source = new PIXI.ImageSource({ resource: img });
const frame = new PIXI.Rectangle(
Col * 40,
Row * 40,
40,
40
);
frameCache[id] = new PIXI.Texture({ source, frame });
}};
//draws textures in a 30x30 grid
function drawMap(){
const tex = frameCache[0];
for (let x = 0; x < 30; x++){
for (let y = 0; y < 30; y++){
const sprite = new PIXI.Sprite(tex);
sprite.x = x * 40;
sprite.y = y * 40;
app.stage.addChild(sprite);
}}
}
I am not sure where to even start when trying to fix this.I have tried putting all the sprites into one image and then putting it back onto the canvas but it didn’t make a difference.
