Jump to content

game.add.audio vs game.sound.add


Recommended Posts

Field "game.add" refers to GameObjectFactory, and its function "audio" looks as following:
Phaser.GameObjectFactory.prototype = {
    audio: function (key, volume, loop, connect) {         
        return this.game.sound.add(key, volume, loop, connect);

So there's precisely zero difference since both do exactly the same thing. From really pedantic standpoint, "game.sound.add" is marginally faster performing since you don't have to reference the GameObjectFactory first nor call its wrapper function - not that it's relevant, with the kind of frequency you'd call this function.

You can use whichever you find better fitting with the rest of your code.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...