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
* Adds the given Game Object, or array of Game Objects, to this Container.
88
+
*
89
+
* @method Phaser.GameObjects.Container#add
90
+
* @since 3.4.0
91
+
*
92
+
* @param {(Phaser.GameObjects.GameObject|Phaser.GameObjects.GameObject[])} gameObject - The Game Object, or array of Game Objects, to add to this Container.
93
+
*
94
+
* @return {Phaser.GameObjects.Container} This Container instance.
95
+
*/
28
96
add: function(gameObject)
29
97
{
30
-
if(gameObject.type==='Container')
98
+
if(!Array.isArray(gameObject))
31
99
{
32
-
gameObject.parentContainer=this;
100
+
gameObject=[gameObject];
33
101
}
34
-
if(this.children.indexOf(gameObject)<0)
102
+
103
+
for(vari=0;i<gameObject.length;i++)
35
104
{
36
-
this.children.push(gameObject);
105
+
varentry=gameObject[i];
106
+
107
+
if(entry.type==='Container')
108
+
{
109
+
entry.parentContainer=this;
110
+
}
111
+
112
+
if(this.children.indexOf(entry)===-1)
113
+
{
114
+
this.children.push(entry);
115
+
}
37
116
}
117
+
38
118
returnthis;
39
119
},
40
120
121
+
/**
122
+
* Removes a Game Object from this Container.
123
+
*
124
+
* @method Phaser.GameObjects.Container#remove
125
+
* @since 3.4.0
126
+
*
127
+
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to remove from this Container.
128
+
*
129
+
* @return {Phaser.GameObjects.Container} This Container instance.
130
+
*/
41
131
remove: function(gameObject)
42
132
{
43
133
varindex=this.children.indexOf(gameObject);
44
-
if(index>=0)
134
+
135
+
if(index!==-1)
45
136
{
46
137
if(gameObject.type==='Container')
47
138
{
48
139
gameObject.parentContainer=null;
49
140
}
141
+
50
142
this.children.splice(index,1);
51
143
}
144
+
52
145
returnthis;
53
146
},
54
147
55
-
pointToContainer: function(pointSrc,pointDst)
148
+
/**
149
+
* Takes a Point-like object, such as a Vector2, Geom.Point or object with public x and y properties,
150
+
* and transforms it into the space of this Container, then returns it in the output object.
* @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} source - The Source Point to be transformed.
156
+
* @param {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} [output] - A destination object to store the transformed point in. If none given a Vector2 will be created and returned.
157
+
*
158
+
* @return {(object|Phaser.Geom.Point|Phaser.Math.Vector2)} The transformed point.
0 commit comments