The Bounds component in phaser ce
When working with one or more sprites or display objects in Phaser ce there might come a time when the bounds of a sprite are of interest. These are simple values like the y position of the sprite plus its height which results in the bottom y position of the sprite. In phaser ce there is no need to write my own code to fine these values because they are part of the bounds component. In some cases it might be necessary to world with these values, and if so they are there all ready at the instance of the display object thanks to this component. This component also adds two useful methods that can be used to align one display object with another as well. Although This component by itself does not do anything with collision detection, it does maintain properties that are needed for things like bounding box collision detection.
1 - What to know
1.1 - This is a phaser ce 2.x post
In this post I am using phaser Community Edition 2.11.1 of phaser.
2 - Bounds properties that are added by the bounds component
So the bounds component adds a bunch of properties that get updated each frame tick along with many other things. So if for some reason you need the y position that is at the bottom of the sprite there is no need to preform the extra operation to get that value because it is all ready a property of the sprite object.
In this example I am logging all of the properties that the bounds component adds and updates for the sprite.
3 - The alignIn method
The bounds component also gives a method that can be used to align a sprite relative to another sprite. It can be used with a number of directional constants other then that of Phaser.BOTTOM_RIGHT which would be the kind of behavior if one where to just align one sprite with another manually.
4 - Conclusion
Thats it for today the bounds component is a fairly simple component that just adds a few properties, and two methods.