Vexen Crabtree Posted June 30, 2018 Share Posted June 30, 2018 When we want to go find the documentation for Phaser3 classes, how do we know where to look? For example: this.physics.add.collider(levelData.dynDoors, glPlayer, door_enter); A namespace? You might think that the "Phaser.Physics" namespace was a good place to look (once selecting which graphics engine you're using - Arcade in my case), but, there's no method called "Add" there. [http://localhost/docs/Phaser.Physics.Arcade.html]. A class? So the next thing to try might be to find the class for Phaser.Physics (doesn't exist), so maybe it is Phaser.Physics.Arcade.something . I could guess that it is Phaser.Physics.Arcade.Collider (possibly add.collider is documented in Collider.Add, or something...). There isn't a ".add" in there, but the documentation page does open with a "new Collider(....)" description. So perhaps physics.add.collider invokes a new collider - makes sense! But, the description for new Collider doesn't match the code. Code: levelData.layer = levelData.tilemap.createDynamicLayer(0, levelData.tileset, 0, 0); this.physics.add.collider(glPlayer.body, levelData.layer); this.physics.add.collider(dynCreatures, levelData.layer); this.physics.add.collider(levelData.dynDoors, levelData.layer); this.physics.add.collider(dynBoulders, levelData.layer); As in, add.collider accepts two parameters, but the "new Colldier" description has a list of 7 mandatory parameters. From http://localhost/docs/Phaser.Physics.Arcade.Collider.html. Phaser.Physics.Arcade.Collider [description] new Collider(world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext) I've tried adding colliderCallback and overlapOnly parameters, but can't get them to work - probably because I haven't found the correct bit of documentation for physics.add.collider. This approach (of looking in Namespaces, Classes, Events, for documentation to match Examples and existing code is very often long-winded and I think my basic method must be wrong. I know the documentation is behind the development, but any ideas? Fiona and scope2229 1 1 Link to comment Share on other sites More sharing options...
samme Posted June 30, 2018 Share Posted June 30, 2018 ArcadePhysics#add → Arcade.Factory#collider Vexen Crabtree and scope2229 2 Link to comment Share on other sites More sharing options...
Vexen Crabtree Posted June 30, 2018 Author Share Posted June 30, 2018 Ah, so on the documentation that's in Classes > Phaser.Physics.Arcade.ArcadePhysics , item "add :Phaser.Physics.Arcade.Factory". It's obvious (ish) in retrospect, but difficult to get there from scratch! So it must be the same with all the physics modules (just thinking out loud for the benefit of others); the physics.add methods are in places like Physics.Impact.ImpactPhysics, and Physics.Matter.MatterPhysics . Thanks for the quick and terse reply! Link to comment Share on other sites More sharing options...
samme Posted July 1, 2018 Share Posted July 1, 2018 If you do console.log(this) from a scene it should identify the classes, which will help. Vexen Crabtree and scope2229 1 1 Link to comment Share on other sites More sharing options...
Recommended Posts