From 22c46b5c148e5020ea2324cd83a6af5793da0234 Mon Sep 17 00:00:00 2001 From: WenhaiLin Date: Mon, 4 May 2015 10:07:37 +0800 Subject: [PATCH] Label:Fixed the character positions could be wrong if `getLetter(letterIndex)` get called. --- cocos/2d/CCLabel.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index ef9a580ef5..f345608449 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -628,13 +628,15 @@ void Label::alignText() letterSprite = dynamic_cast(child); if (letterSprite) { - uvRect.size.height = _lettersInfo[tag].def.height; - uvRect.size.width = _lettersInfo[tag].def.width; - uvRect.origin.x = _lettersInfo[tag].def.U; - uvRect.origin.y = _lettersInfo[tag].def.V; + auto& letterDef = _lettersInfo[tag].def; + uvRect.size.height = letterDef.height; + uvRect.size.width = letterDef.width; + uvRect.origin.x = letterDef.U; + uvRect.origin.y = letterDef.V; - letterSprite->setTexture(textures.at(_lettersInfo[tag].def.textureID)); + letterSprite->setTexture(textures.at(letterDef.textureID)); letterSprite->setTextureRect(uvRect); + letterSprite->setPosition(_lettersInfo[tag].position); } ++index; }