So when making a Phaser ce project I end up with a lot of sprites, and other display objects. As such there needs to be a way to obtain a reference to a single specific display object by some kind of id, or name. That is to grab at display objects in phaser in a similar fashion to that of id attributes when it comes to html elements with document.getElementById. After playing around with phaser for a while I came across just such a method called game.world.getByName. This post will be a quick overview of this method, as a way to grab references to display objects across the different methods of a state object in phaser, and why game.world.getByName is the document.getElementById of phaser ce.
In this example I will be setting a name property to a text object, which is one of many display objects in phaser ce. Once I have set the name, I can then get a reference to it in other methods within the state object, such as the update method.
Using game.world.getByName, along with name properties is one way to go about grabbing references to display objects when making a phaser ce project. However it is not the only way. If you prefer to just use global variables, or an object that is appended to the state, or game objects I will not laugh at you for it. What matters most to me is the nature of your project, and what really truly sets it apart from others. I tend to like this way of handling this, but that is just my style, and in some cases it might not be the smartest play.