@@ -230,7 +230,14 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{
230
230
231
231
self . _config = newConf ;
232
232
self . _fntFile = fntFile ;
233
- texture = cc . textureCache . addImage ( newConf . atlasName ) ;
233
+ var spriteFrameBaseName = cc . path . basename ( newConf . atlasName ) ;
234
+ var spriteFrame = cc . spriteFrameCache . getSpriteFrame ( spriteFrameBaseName ) ;
235
+ if ( spriteFrame ) {
236
+ texture = spriteFrame . getTexture ( ) ;
237
+ this . _spriteFrame = spriteFrame ;
238
+ } else {
239
+ texture = cc . textureCache . addImage ( newConf . atlasName ) ;
240
+ }
234
241
var locIsLoaded = texture . isLoaded ( ) ;
235
242
self . _textureLoaded = locIsLoaded ;
236
243
if ( ! locIsLoaded ) {
@@ -336,15 +343,30 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{
336
343
rect . x += self . _imageOffset . x ;
337
344
rect . y += self . _imageOffset . y ;
338
345
346
+ var isRotated = false ;
347
+ if ( this . _spriteFrame ) {
348
+ var textureWidth = locTexture . width ;
349
+ var spriteFrameRect = this . _spriteFrame . _rect ;
350
+ if ( ! this . _spriteFrame . _rotated ) {
351
+ rect . x = rect . x + spriteFrameRect . x ;
352
+ rect . y = rect . y + spriteFrameRect . y ;
353
+ } else {
354
+ isRotated = true ;
355
+ var originalX = rect . x ;
356
+ rect . x = rect . y + spriteFrameRect . x ;
357
+ rect . y = originalX + spriteFrameRect . y ;
358
+ }
359
+ }
360
+
339
361
var fontChar = self . getChildByTag ( i ) ;
340
362
341
363
if ( ! fontChar ) {
342
364
fontChar = new cc . Sprite ( ) ;
343
- fontChar . initWithTexture ( locTexture , rect , false ) ;
365
+ fontChar . initWithTexture ( locTexture , rect , isRotated ) ;
344
366
fontChar . _newTextureWhenChangeColor = true ;
345
367
this . addChild ( fontChar , 0 , i ) ;
346
368
} else {
347
- cmd . _updateCharTexture ( fontChar , rect , key ) ;
369
+ cmd . _updateCharTexture ( fontChar , rect , key , isRotated ) ;
348
370
}
349
371
350
372
// Apply label properties
0 commit comments