I'm trying to learn an HTML5 framework for videogame development, called phaser, so I'm in the tutorial of here , where it says 'Loading Assets' there is a preload
function that loads the images or assets commonly called 'assets' of the game, the code of the function is this:
function preload ()
{
this.load.image('sky', 'src/games/firstgame/assets/sky.png');
this.load.image('ground', 'src/games/firstgame/assets/platform.png');
this.load.image('star', 'src/games/firstgame/assets/star.png');
this.load.image('bomb', 'src/games/firstgame/assets/bomb.png');
this.load.spritesheet('dude',
'src/games/firstgame/assets/dude.png',
{ frameWidth: 32, frameHeight: 48 }
);
}
What strikes me about this is that within the lines of the function code is called a parameter or method load
, and then image
is that the functions within javascript are objects so that the statement this
reference to the same object function in this case preload
. I tried to find some kind of documentation of this method or parameter load
to know if it is some type of object defined in Javascript but I did not find anything, I would like to understand why you can write what is shown in the function since I think that it is not a defined method within the Function class of Javascript