Skip to content

Commit 7c28a7b

Browse files
committed
Bob.reset will now reset the position, frame, flip, visible and alpha values of the Bob, plus JSDocs completed.
1 parent bfa2902 commit 7c28a7b

3 files changed

Lines changed: 103 additions & 48 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Updates
88

99
* Container.setInteractive can now be called without any arguments as long as you have called Container.setSize first (thanks rex)
10+
* Bob.reset will now reset the position, frame, flip, visible and alpha values of the Bob.
1011

1112
### Bug Fixes
1213

src/gameobjects/blitter/Blitter.js

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ var GameObject = require('../GameObject');
1313
var List = require('../../structs/List');
1414

1515
/**
16-
* @callback Phaser.GameObjects.Blitter.BlitterFromCallback
16+
* @callback Phaser.GameObjects.Blitter.CreateCallback
1717
*
18-
* @param {Phaser.GameObjects.Blitter} blitter - [description]
19-
* @param {integer} index - [description]
18+
* @param {Phaser.GameObjects.Blitter.Bob} bob - The Bob that was created by the Blitter.
19+
* @param {integer} index - The position of the Bob within the Blitter display list.
2020
*/
2121

2222
/**
@@ -89,7 +89,8 @@ var Blitter = new Class({
8989
this.initPipeline('TextureTintPipeline');
9090

9191
/**
92-
* [description]
92+
* The children of this Blitter.
93+
* This List contains all of the Bob objects created by the Blitter.
9394
*
9495
* @name Phaser.GameObjects.Blitter#children
9596
* @type {Phaser.Structs.List.<Phaser.GameObjects.Blitter.Bob>}
@@ -98,20 +99,33 @@ var Blitter = new Class({
9899
this.children = new List();
99100

100101
/**
101-
* [description]
102+
* A transient array that holds all of the Bobs that will be rendered this frame.
103+
* The array is re-populated whenever the dirty flag is set.
102104
*
103105
* @name Phaser.GameObjects.Blitter#renderList
104106
* @type {Phaser.GameObjects.Blitter.Bob[]}
105107
* @default []
108+
* @private
106109
* @since 3.0.0
107110
*/
108111
this.renderList = [];
109112

113+
/**
114+
* Is the Blitter considered dirty?
115+
* A 'dirty' Blitter has had its child count changed since the last frame.
116+
*
117+
* @name Phaser.GameObjects.Blitter#dirty
118+
* @type {boolean}
119+
* @since 3.0.0
120+
*/
110121
this.dirty = false;
111122
},
112123

113124
/**
114-
* [description]
125+
* Creates a new Bob in this Blitter.
126+
*
127+
* The Bob is created at the given coordinates, relative to the Blitter and uses the given frame.
128+
* A Bob can use any frame belonging to the texture bound to the Blitter.
115129
*
116130
* @method Phaser.GameObjects.Blitter#create
117131
* @since 3.0.0
@@ -148,15 +162,15 @@ var Blitter = new Class({
148162
},
149163

150164
/**
151-
* [description]
165+
* Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback.
152166
*
153167
* @method Phaser.GameObjects.Blitter#createFromCallback
154168
* @since 3.0.0
155169
*
156-
* @param {Phaser.GameObjects.Blitter.BlitterFromCallback} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob.
170+
* @param {Phaser.GameObjects.Blitter.CreateCallback} callback - The callback to invoke after creating a bob. It will be sent two arguments: The Bob and the index of the Bob.
157171
* @param {integer} quantity - The quantity of Bob objects to create.
158172
* @param {(string|integer|Phaser.Textures.Frame|string[]|integer[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture.
159-
* @param {boolean} [visible=true] - [description]
173+
* @param {boolean} [visible=true] - Should the created Bob render or not?
160174
*
161175
* @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created.
162176
*/
@@ -175,14 +189,19 @@ var Blitter = new Class({
175189
},
176190

177191
/**
178-
* [description]
192+
* Creates multiple Bobs in one call.
193+
*
194+
* The amount created is controlled by a combination of the `quantity` argument and the number of frames provided.
195+
*
196+
* If the quantity is set to 10 and you provide 2 frames, then 20 Bobs will be created. 10 with the first
197+
* frame and 10 with the second.
179198
*
180199
* @method Phaser.GameObjects.Blitter#createMultiple
181200
* @since 3.0.0
182201
*
183202
* @param {integer} quantity - The quantity of Bob objects to create.
184203
* @param {(string|integer|Phaser.Textures.Frame|string[]|integer[]|Phaser.Textures.Frame[])} [frame] - The Frame the Bobs will use. It must be part of the Blitter Texture.
185-
* @param {boolean} [visible=true] - [description]
204+
* @param {boolean} [visible=true] - Should the created Bob render or not?
186205
*
187206
* @return {Phaser.GameObjects.Blitter.Bob[]} An array of Bob objects that were created.
188207
*/
@@ -211,22 +230,23 @@ var Blitter = new Class({
211230
},
212231

213232
/**
214-
* [description]
233+
* Checks if the given child can render or not, by checking its `visible` and `alpha` values.
215234
*
216235
* @method Phaser.GameObjects.Blitter#childCanRender
217236
* @since 3.0.0
218237
*
219-
* @param {Phaser.GameObjects.Blitter.Bob} child - [description]
238+
* @param {Phaser.GameObjects.Blitter.Bob} child - The Bob to check for rendering.
220239
*
221-
* @return {boolean} [description]
240+
* @return {boolean} Returns `true` if the given child can render, otherwise `false`.
222241
*/
223242
childCanRender: function (child)
224243
{
225244
return (child.visible && child.alpha > 0);
226245
},
227246

228247
/**
229-
* [description]
248+
* Returns an array of Bobs to be rendered.
249+
* If the Blitter is dirty then a new list is generated and stored in `renderList`.
230250
*
231251
* @method Phaser.GameObjects.Blitter#getRenderList
232252
* @since 3.0.0
@@ -245,7 +265,7 @@ var Blitter = new Class({
245265
},
246266

247267
/**
248-
* [description]
268+
* Removes all Bobs from the children List and clears the dirty flag.
249269
*
250270
* @method Phaser.GameObjects.Blitter#clear
251271
* @since 3.0.0

0 commit comments

Comments
 (0)