You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Filter.addToWorld allows you to quickly create a Phaser.Image object at the given position and size, with the Filter ready applied to it. This can eliminate lots of duplicate code.
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -262,6 +262,7 @@ If you are an exceptional JavaScript developer and would like to join the Phaser
262
262
* Group.resetChild is a new method that allows you to call both `child.reset` and/or `child.loadTexture` on the given child object. This is used internally by `getFirstDead` and similar, but is made public so you can use it as a group iteration callback. Note that the child must have public `reset` and `loadTexture` methods to be valid for the call.
263
263
* Group.getFirstDead, Group.getFirstAlive and Group.getFirstExists all have new optional arguments: `createIfNull`, `x`, `y`, `key` and `frame`. If the method you call cannot find a matching child (i.e. getFirstDead cannot find any dead children) then the optional `createIfNull` allows you to instantly create a new child in the group using the position and texture arguments to do so. This allows you to always get a child back from the Group and remove the need to do null checks and Group inserts from your game code. The same arguments can also be used in a different way: if `createIfNull` is false AND you provide the extra arguments AND a child is found then it will be passed to the new `Group.resetChild` method. This allows you to retrieve a child from the Group and have it reset and instantly ready for use in your game without any extra code.
264
264
* P2.Body.removeCollisionGroup allows you to remove the given CollisionGroup, or array of CollisionGroups, from the list of groups that a body will collide with and updates the collision masks (thanks @Garbanas#2047)
265
+
* Filter.addToWorld allows you to quickly create a Phaser.Image object at the given position and size, with the Filter ready applied to it. This can eliminate lots of duplicate code.
Copy file name to clipboardExpand all lines: src/core/Filter.js
+54Lines changed: 54 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -143,6 +143,60 @@ Phaser.Filter.prototype = {
143
143
144
144
},
145
145
146
+
/**
147
+
* Creates a new Phaser.Image object using a blank texture and assigns
148
+
* this Filter to it. The image is then added to the world.
149
+
*
150
+
* If you don't provide width and height values then Filter.width and Filter.height are used.
151
+
*
152
+
* If you do provide width and height values then this filter will be resized to match those
153
+
* values.
154
+
*
155
+
* @method Phaser.Filter#addToWorld
156
+
* @param {number} [x=0] - The x coordinate to place the Image at.
157
+
* @param {number} [y=0] - The y coordinate to place the Image at.
158
+
* @param {number} [width] - The width of the Image. If not specified (or null) it will use Filter.width. If specified Filter.width will be set to this value.
159
+
* @param {number} [height] - The height of the Image. If not specified (or null) it will use Filter.height. If specified Filter.height will be set to this value.
160
+
* @param {number} [anchorX=0] - Set the x anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right.
161
+
* @param {number} [anchorY=0] - Set the y anchor point of the Image. A value between 0 and 1, where 0 is the top-left and 1 is bottom-right.
162
+
* @return {Phaser.Image} The newly added Image object.
0 commit comments