@@ -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
this . init ( ) ;
52
59
@@ -188,12 +195,128 @@ ccui.PageViewIndicator = ccui.ProtectedNode.extend(/** @lends ccui.PageViewIndic
188
195
return this . _currentIndexNode . getColor ( ) ;
189
196
} ,
190
197
198
+ /**
199
+ * Sets color of index nodes
200
+ * @param {cc.Color } indexNodesColor
201
+ */
202
+ setIndexNodesColor : function ( indexNodesColor )
203
+ {
204
+ this . _indexNodesColor = indexNodesColor ;
205
+
206
+ for ( var i = 0 ; i < this . _indexNodes . length ; ++ i )
207
+ {
208
+ this . _indexNodes [ i ] . setColor ( indexNodesColor ) ;
209
+ }
210
+ } ,
211
+
212
+ /**
213
+ * Gets color of index nodes
214
+ * @returns {cc.Color }
215
+ */
216
+ getIndexNodesColor : function ( )
217
+ {
218
+ var locRealColor = this . _indexNodesColor ;
219
+ return cc . color ( locRealColor . r , locRealColor . g , locRealColor . b , locRealColor . a ) ;
220
+ } ,
221
+
222
+ /**
223
+ * Sets scale of index nodes
224
+ * @param {Number } indexNodesScale
225
+ */
226
+ setIndexNodesScale : function ( indexNodesScale )
227
+ {
228
+ if ( this . _indexNodesScale === indexNodesScale )
229
+ {
230
+ return ;
231
+ }
232
+ this . _indexNodesScale = indexNodesScale ;
233
+
234
+ this . _currentIndexNode . setScale ( indexNodesScale ) ;
235
+
236
+ for ( var i = 0 ; i < this . _indexNodes . length ; ++ i )
237
+ {
238
+ this . _indexNodes [ i ] . setScale ( this , _indexNodesScale ) ;
239
+ }
240
+
241
+ this . _rearrange ( ) ;
242
+ } ,
243
+
244
+ /**
245
+ * Gets scale of index nodes
246
+ * @returns {Number }
247
+ */
248
+ getIndexNodesScale : function ( )
249
+ {
250
+ return this . _indexNodesScale ;
251
+ } ,
252
+
253
+ /**
254
+ * Sets texture of index nodes
255
+ * @param {String } texName
256
+ * @param {ccui.Widget.LOCAL_TEXTURE | ccui.Widget.PLIST_TEXTURE } [texType = ccui.Widget.LOCAL_TEXTURE]
257
+ */
258
+ setIndexNodesTexture : function ( texName , texType )
259
+ {
260
+ if ( texType === undefined )
261
+ texType = ccui . Widget . LOCAL_TEXTURE ;
262
+
263
+ this . _useDefaultTexture = false ;
264
+ this . _indexNodesTextureFile = texName ;
265
+ this . _indexNodesTexType = texType ;
266
+
267
+ switch ( texType )
268
+ {
269
+ case ccui . Widget . LOCAL_TEXTURE :
270
+ this . _currentIndexNode . setTexture ( texName ) ;
271
+ for ( var i = 0 ; i < this . _indexNodes . length ; ++ i )
272
+ {
273
+ this . _indexNodes [ i ] . setTexture ( texName ) ;
274
+ }
275
+ break ;
276
+ case ccui . Widget . PLIST_TEXTURE :
277
+ this . _currentIndexNode . setSpriteFrame ( texName ) ;
278
+ for ( var i = 0 ; i < this . _indexNodes . length ; ++ i )
279
+ {
280
+ this . _indexNodes [ i ] . setSpriteFrame ( texName ) ;
281
+ }
282
+ break ;
283
+ default :
284
+ break ;
285
+ }
286
+
287
+ this . _rearrange ( ) ;
288
+ } ,
289
+
191
290
_increaseNumberOfPages : function ( )
192
291
{
193
- var image = new Image ( ) ;
194
- image . src = ccui . PageViewIndicator . CIRCLE_IMAGE ;
292
+ var indexNode ;
293
+
294
+ if ( this . _useDefaultTexture )
295
+ {
296
+ var image = new Image ( ) ;
297
+ image . src = ccui . PageViewIndicator . CIRCLE_IMAGE ;
298
+
299
+ indexNode = new cc . Sprite ( image ) ;
300
+ }
301
+ else
302
+ {
303
+ indexNode = new cc . Sprite ( ) ;
304
+ switch ( this . _indexNodesTexType )
305
+ {
306
+ case ccui . Widget . LOCAL_TEXTURE :
307
+ indexNode . initWithFile ( this . _indexNodesTextureFile ) ;
308
+ break ;
309
+ case ccui . Widget . PLIST_TEXTURE :
310
+ indexNode . initWithSpriteFrameName ( this . _indexNodesTextureFile ) ;
311
+ break ;
312
+ default :
313
+ break ;
314
+ }
315
+ }
316
+
317
+ indexNode . setColor ( this . _indexNodesColor ) ;
318
+ indexNode . setScale ( this . _indexNodesScale ) ;
195
319
196
- var indexNode = new cc . Sprite ( image ) ;
197
320
this . addProtectedChild ( indexNode ) ;
198
321
this . _indexNodes . push ( indexNode ) ;
199
322
} ,
0 commit comments