Phaser Posted July 3, 2016 Share Posted July 3, 2016 What is the best way to find the source code for a method to understand how it works? As sometimes I can't seem to find the documentation in the API or find I need more details... just a silly example that I find difficult... in the examples game.load.image('menu', 'assets/buttons/number-buttons-90x90.png', 270, 180); When I look up API it says image(key, url, overwrite) well clearly 270 and 180 does not correspond to this overwrite boolean parameter... Is this a mistake in the API or how do I find the code to this instance of game.load.image? Link to comment Share on other sites More sharing options...
noobshit Posted July 4, 2016 Share Posted July 4, 2016 It has to be mistake in examples. Code will work, because: game.load.image(key, url, overwrite) game.load.image('menu', 'assets/buttons/number-buttons-90x90.png', 270, 180); key = 'menu'; // correct url = 'assets/buttons/number-buttons-90x90.png'; // correct overwrite = 270; // 270 in logical expression is true, no problem... // 180 will be ignored Javascript... thats the reason I'm using Typescript: Str1ngS 1 Link to comment Share on other sites More sharing options...
drhayes Posted July 5, 2016 Share Posted July 5, 2016 Here is the documentation site: http://phaser.io/docs/2.5.0/index The "via" column is a big clue as to what objects are where: anything in that column is available via (get it?) a property on game or, sometimes, on a stage. In this case, "game.load.image" is a method on the Phaser.Loader: http://phaser.io/docs/2.5.0/Phaser.Loader.html#image Thus, here is the source code for that method: https://github.com/photonstorm/phaser/blob/32326ae2434fb47d24def0b21ed8b818fbc72f55/src/loader/Loader.js#L693 Often the display object classes use Components, so their methods are in another castle code-wise, but most of the time it's pretty straightforward to find the implementation you're looking for. lewster32 1 Link to comment Share on other sites More sharing options...
Recommended Posts