|
1 | 1 | /** |
2 | | -* InWorld Component Features. |
| 2 | +* The InWorld component checks if a Game Object is within the Game World Bounds. |
| 3 | +* An object is considered as being "in bounds" so long as its own bounds intersects at any point with the World bounds. |
| 4 | +* If the AutoCull component is enabled on the Game Object then it will check the Game Object against the Camera bounds as well. |
3 | 5 | * |
4 | 6 | * @class |
5 | 7 | */ |
@@ -59,30 +61,37 @@ Phaser.Component.InWorld.preUpdate = function () { |
59 | 61 | Phaser.Component.InWorld.prototype = { |
60 | 62 |
|
61 | 63 | /** |
62 | | - * If true the Sprite checks if it is still within the world each frame, when it leaves the world it dispatches Sprite.events.onOutOfBounds |
63 | | - * and optionally kills the sprite (if Sprite.outOfBoundsKill is true). By default this is disabled because the Sprite has to calculate its |
64 | | - * bounds every frame to support it, and not all games need it. Enable it by setting the value to true. |
| 64 | + * If this is set to `true` the Game Object checks if it is within the World bounds each frame. |
| 65 | + * When it is no longer within or intersecting the world bounds it dispatches the `onOutOfBounds` event. |
| 66 | + * If it was *previously* out of bounds but is now intersecting the world bounds again it dispatches the `onEnterBounds` event. |
| 67 | + * It also optionally kills the Game Object if `outOfBoundsKill` is `true`. |
| 68 | + * When `checkWorldBounds` is enabled it forces the Game Object has to calculate its full bounds every frame. |
| 69 | + * This is a relatively expensive operation, especially if enabled on hundreds of Game Objects. So enable it only if you know it's required, |
| 70 | + * or you have tested performance and find it acceptable. |
| 71 | + * |
65 | 72 | * @property {boolean} checkWorldBounds |
66 | 73 | * @default |
67 | 74 | */ |
68 | 75 | checkWorldBounds: false, |
69 | 76 |
|
70 | 77 | /** |
71 | | - * @property {boolean} outOfBoundsKill - If true Sprite.kill is called as soon as Sprite.inWorld returns false, as long as Sprite.checkWorldBounds is true. |
| 78 | + * If this and the `checkWorldBounds` property are both set to `true` then the `kill` method is called as soon as `inWorld` returns false. |
| 79 | + * |
| 80 | + * @property {boolean} outOfBoundsKill |
72 | 81 | * @default |
73 | 82 | */ |
74 | 83 | outOfBoundsKill: false, |
75 | 84 |
|
76 | 85 | /** |
77 | | - * @property {boolean} _outOfBoundsFired - Internal cache var. |
| 86 | + * @property {boolean} _outOfBoundsFired - Internal state var. |
78 | 87 | * @private |
79 | 88 | */ |
80 | 89 | _outOfBoundsFired: false, |
81 | 90 |
|
82 | 91 | /** |
83 | | - * Checks if the Sprite bounds are within the game world, otherwise false if fully outside of it. |
| 92 | + * Checks if the Game Objects bounds are within, or intersect at any point with the Game World bounds. |
84 | 93 | * |
85 | | - * @property {boolean} inWorld - True if the Sprite bounds is within the game world, even if only partially. Otherwise false if fully outside of it. |
| 94 | + * @property {boolean} inWorld |
86 | 95 | * @readonly |
87 | 96 | */ |
88 | 97 | inWorld: { |
|
0 commit comments