Hi,
Trying to load images using a function.
When we run in Internet browser, it crashes and shows below error in browser console.
We are having difficulty with this constantly.
Please look at below JS source code and the error:
Thanks!
Jesse Lee
//--------------------------------------------------------------------------------------------------------------
function LoadSprite (spriteIndex, filePath, spriteDepth, spriteAlpha)
{
Sprites[spriteIndex] = this.load.image('Sprites[spriteIndex]', filePath);
// ^-- ERROR: "Uncaught TypeError: Cannot read properties of undefined (reading 'image')"?
Sprites[spriteIndex] = this.add.image(-99999, -99999, 'Sprites[spriteIndex]');
Sprites[spriteIndex].setDepth(spriteDepth);
DrawSprite(Sprites[spriteIndex], 320, 180, 1.0, 1.0, 0, 255, 255, 255, spriteAlpha);
}
//--------------------------------------------------------------------------------------------------------------
function LoadAllSpritesAndInitialize ()
{
for (index = 0; index < SpritesMax; index++)
{
if (index === 0)
{
LoadSprite(index, 'data/images/backgrounds/BG_Screen_Fading.png', 999, 0);
}
}
}