I've seen this question before, but I'm still struggling to find a solution that fits my situation.
In my file, I have defined certain values and want to loop through them. The issue arises in the following part of the code:
preloadImages(){
this.load.setPath("./assets/images");
for (const key in STATIC.IMAGES) {
if (STATIC.IMAGES.hasOwnProperty(key)) {
this.load.image(STATIC.IMAGES[key], STATIC.IMAGES[key]);
}
}
}
The error seems to stem from the calls to STATIC.IMAGES[key]. The STATIC object is sourced from a separate file containing:
export const STATIC = {
SCENES: {
LOAD: "LOAD",
MENU: "MENU"
},
IMAGES: {
MENU_BG :"bg.png",
MENU_TITLE: "title.png",
MENU_PLAY: "play.png",
MENU_SETTINGS: "settings.png",
MENU_CREDITS: "credits.png",
MENU_SPEAKER: "speaker.png",
MENU_SPEAKER_MUTE: "speaker_mute.png"
},
SPRITES: {
LOOP: {
name: "loop.png",
size: 64
}
},
AUDIOS: {
BG_MUSIC: "airtone.mp3",
POP: "pop.mp3",
WOOSH: "woosh.mp3"
}};
I'm unsure of why this issue is occurring and how to resolve it.