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
* @property {any} cursor - The current display object that the Group cursor is pointing to. You can move the cursor with Group.next and Group.previous.
86
+
* The cursor is a simple way to iterate through the objects in a Group using the Group.next and Group.previous functions.
87
+
* The cursor is set to the first child added to the Group and doesn't change unless you call next, previous or set it directly with Group.cursor.
88
+
* @property {any} cursor - The current display object that the Group cursor is pointing to.
87
89
*/
88
90
this.cursor=null;
89
91
@@ -116,6 +118,11 @@ Phaser.Group.prototype = {
116
118
this._container.addChild(child);
117
119
118
120
child.updateTransform();
121
+
122
+
if(this.cursor===null)
123
+
{
124
+
this.cursor=child;
125
+
}
119
126
}
120
127
121
128
returnchild;
@@ -145,6 +152,11 @@ Phaser.Group.prototype = {
145
152
this._container.addChildAt(child,index);
146
153
147
154
child.updateTransform();
155
+
156
+
if(this.cursor===null)
157
+
{
158
+
this.cursor=child;
159
+
}
148
160
}
149
161
150
162
returnchild;
@@ -197,6 +209,11 @@ Phaser.Group.prototype = {
197
209
198
210
child.updateTransform();
199
211
212
+
if(this.cursor===null)
213
+
{
214
+
this.cursor=child;
215
+
}
216
+
200
217
returnchild;
201
218
202
219
},
@@ -233,6 +250,55 @@ Phaser.Group.prototype = {
233
250
this._container.addChild(child);
234
251
child.updateTransform();
235
252
253
+
if(this.cursor===null)
254
+
{
255
+
this.cursor=child;
256
+
}
257
+
258
+
}
259
+
260
+
},
261
+
262
+
/**
263
+
* Advances the Group cursor to the next object in the Group. If it's at the end of the Group it wraps around to the first object.
264
+
*
265
+
* @method Phaser.Group#next
266
+
*/
267
+
next: function(){
268
+
269
+
if(this.cursor)
270
+
{
271
+
// Wrap the cursor?
272
+
if(this.cursor==this._container.last)
273
+
{
274
+
this.cursor=this._container._iNext;
275
+
}
276
+
else
277
+
{
278
+
this.cursor=this.cursor._iNext;
279
+
}
280
+
}
281
+
282
+
},
283
+
284
+
/**
285
+
* Moves the Group cursor to the previous object in the Group. If it's at the start of the Group it wraps around to the last object.
0 commit comments