@@ -35,6 +35,12 @@ ccui.PageViewIndicator = ccui.ProtectedNode.extend(/** @lends ccui.PageViewIndic
35
35
_indexNodes : null ,
36
36
_currentIndexNode : null ,
37
37
_spaceBetweenIndexNodes : 0 ,
38
+ _indexNodesScale : 1.0 ,
39
+ _indexNodesColor : null ,
40
+ _useDefaultTexture : true ,
41
+ _indexNodesTextureFile : "" ,
42
+ _indexNodesTexType : ccui . Widget . LOCAL_TEXTURE ,
43
+
38
44
_className : "PageViewIndicator" ,
39
45
40
46
/**
@@ -47,6 +53,7 @@ ccui.PageViewIndicator = ccui.ProtectedNode.extend(/** @lends ccui.PageViewIndic
47
53
this . _direction = ccui . ScrollView . DIR_HORIZONTAL ;
48
54
this . _indexNodes = [ ] ;
49
55
this . _spaceBetweenIndexNodes = ccui . PageViewIndicator . SPACE_BETWEEN_INDEX_NODES_DEFAULT ;
56
+ this . _indexNodesColor = cc . color . WHITE ;
50
57
51
58
var image = new Image ( ) ;
52
59
image . src = ccui . PageViewIndicator . CIRCLE_IMAGE ;
@@ -174,12 +181,128 @@ ccui.PageViewIndicator = ccui.ProtectedNode.extend(/** @lends ccui.PageViewIndic
174
181
return this . _currentIndexNode . getColor ( ) ;
175
182
} ,
176
183
184
+ /**
185
+ * Sets color of index nodes
186
+ * @param {cc.Color } indexNodesColor
187
+ */
188
+ setIndexNodesColor : function ( indexNodesColor )
189
+ {
190
+ this . _indexNodesColor = indexNodesColor ;
191
+
192
+ for ( var i = 0 ; i < this . _indexNodes . length ; ++ i )
193
+ {
194
+ this . _indexNodes [ i ] . setColor ( indexNodesColor ) ;
195
+ }
196
+ } ,
197
+
198
+ /**
199
+ * Gets color of index nodes
200
+ * @returns {cc.Color }
201
+ */
202
+ getIndexNodesColor : function ( )
203
+ {
204
+ var locRealColor = this . _indexNodesColor ;
205
+ return cc . color ( locRealColor . r , locRealColor . g , locRealColor . b , locRealColor . a ) ;
206
+ } ,
207
+
208
+ /**
209
+ * Sets scale of index nodes
210
+ * @param {Number } indexNodesScale
211
+ */
212
+ setIndexNodesScale : function ( indexNodesScale )
213
+ {
214
+ if ( this . _indexNodesScale === indexNodesScale )
215
+ {
216
+ return ;
217
+ }
218
+ this . _indexNodesScale = indexNodesScale ;
219
+
220
+ this . _currentIndexNode . setScale ( indexNodesScale ) ;
221
+
222
+ for ( var i = 0 ; i < this . _indexNodes . length ; ++ i )
223
+ {
224
+ this . _indexNodes [ i ] . setScale ( this , _indexNodesScale ) ;
225
+ }
226
+
227
+ this . _rearrange ( ) ;
228
+ } ,
229
+
230
+ /**
231
+ * Gets scale of index nodes
232
+ * @returns {Number }
233
+ */
234
+ getIndexNodesScale : function ( )
235
+ {
236
+ return this . _indexNodesScale ;
237
+ } ,
238
+
239
+ /**
240
+ * Sets texture of index nodes
241
+ * @param {String } texName
242
+ * @param {ccui.Widget.LOCAL_TEXTURE | ccui.Widget.PLIST_TEXTURE } [texType = ccui.Widget.LOCAL_TEXTURE]
243
+ */
244
+ setIndexNodesTexture : function ( texName , texType )
245
+ {
246
+ if ( texType === undefined )
247
+ texType = ccui . Widget . LOCAL_TEXTURE ;
248
+
249
+ this . _useDefaultTexture = false ;
250
+ this . _indexNodesTextureFile = texName ;
251
+ this . _indexNodesTexType = texType ;
252
+
253
+ switch ( texType )
254
+ {
255
+ case ccui . Widget . LOCAL_TEXTURE :
256
+ this . _currentIndexNode . setTexture ( texName ) ;
257
+ for ( var i = 0 ; i < this . _indexNodes . length ; ++ i )
258
+ {
259
+ this . _indexNodes [ i ] . setTexture ( texName ) ;
260
+ }
261
+ break ;
262
+ case ccui . Widget . PLIST_TEXTURE :
263
+ this . _currentIndexNode . setSpriteFrame ( texName ) ;
264
+ for ( var i = 0 ; i < this . _indexNodes . length ; ++ i )
265
+ {
266
+ this . _indexNodes [ i ] . setSpriteFrame ( texName ) ;
267
+ }
268
+ break ;
269
+ default :
270
+ break ;
271
+ }
272
+
273
+ this . _rearrange ( ) ;
274
+ } ,
275
+
177
276
_increaseNumberOfPages : function ( )
178
277
{
179
- var image = new Image ( ) ;
180
- image . src = ccui . PageViewIndicator . CIRCLE_IMAGE ;
278
+ var indexNode ;
279
+
280
+ if ( this . _useDefaultTexture )
281
+ {
282
+ var image = new Image ( ) ;
283
+ image . src = ccui . PageViewIndicator . CIRCLE_IMAGE ;
284
+
285
+ indexNode = new cc . Sprite ( image ) ;
286
+ }
287
+ else
288
+ {
289
+ indexNode = new cc . Sprite ( ) ;
290
+ switch ( this . _indexNodesTexType )
291
+ {
292
+ case ccui . Widget . LOCAL_TEXTURE :
293
+ indexNode . initWithFile ( this . _indexNodesTextureFile ) ;
294
+ break ;
295
+ case ccui . Widget . PLIST_TEXTURE :
296
+ indexNode . initWithSpriteFrameName ( this . _indexNodesTextureFile ) ;
297
+ break ;
298
+ default :
299
+ break ;
300
+ }
301
+ }
302
+
303
+ indexNode . setColor ( this . _indexNodesColor ) ;
304
+ indexNode . setScale ( this . _indexNodesScale ) ;
181
305
182
- var indexNode = new cc . Sprite ( image ) ;
183
306
this . addProtectedChild ( indexNode ) ;
184
307
this . _indexNodes . push ( indexNode ) ;
185
308
} ,
0 commit comments