Skip to content

Commit a95053c

Browse files
committed
Merge pull request #1716 from dingpinglv/SyncLabelBMFont
Sync cc.LabelBMFont to v3.0
2 parents b93baa7 + 3ba09f1 commit a95053c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cocos2d/labels/CCLabelBMFont.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,9 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{
629629
start_line = false;
630630
startOfWord = -1;
631631
startOfLine = -1;
632-
i+= justSkipped;
632+
//i+= justSkipped;
633+
j--;
634+
skip -= justSkipped;
633635
line++;
634636

635637
if (i >= stringLength)
@@ -733,6 +735,11 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{
733735
if (self._string[ctr].charCodeAt(0) == 10 || self._string[ctr].charCodeAt(0) == 0) {
734736
var lineWidth = 0;
735737
var line_length = last_line.length;
738+
// if last line is empty we must just increase lineNumber and work with next line
739+
if (line_length == 0) {
740+
lineNumber++;
741+
continue;
742+
}
736743
var index = i + line_length - 1 + lineNumber;
737744
if (index < 0) continue;
738745

@@ -918,11 +925,11 @@ cc.LabelBMFont = cc.SpriteBatchNode.extend(/** @lends cc.LabelBMFont# */{
918925
},
919926

920927
_getLetterPosXLeft:function (sp) {
921-
return sp.getPositionX() * this._scaleX + (sp._getWidth() * this._scaleX * sp._getAnchorX());
928+
return sp.getPositionX() * this._scaleX - (sp._getWidth() * this._scaleX * sp._getAnchorX());
922929
},
923930

924931
_getLetterPosXRight:function (sp) {
925-
return sp.getPositionX() * this._scaleX - (sp._getWidth() * this._scaleX * sp._getAnchorX());
932+
return sp.getPositionX() * this._scaleX + (sp._getWidth() * this._scaleX * sp._getAnchorX());
926933
}
927934
});
928935

0 commit comments

Comments
 (0)