Skip to content

Commit

Permalink
Fix label disableeffect (cocos2d#17075)
Browse files Browse the repository at this point in the history
* add toggle rendering type test

* fix label additional kerning

* only substract additionalKerning when bold is enabled
  • Loading branch information
zilongshanren authored and minggo committed Dec 29, 2016
1 parent b57db96 commit 163e730
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
8 changes: 5 additions & 3 deletions cocos/2d/CCLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1217,9 +1217,11 @@ void Label::disableEffect(LabelEffect effect)
setRotationSkewX(0);
break;
case cocos2d::LabelEffect::BOLD:
_boldEnabled = false;
_additionalKerning -= 1;
disableEffect(LabelEffect::SHADOW);
if (_boldEnabled) {
_boldEnabled = false;
_additionalKerning -= 1;
disableEffect(LabelEffect::SHADOW);
}
break;
case cocos2d::LabelEffect::UNDERLINE:
if (_underlineNode) {
Expand Down
43 changes: 41 additions & 2 deletions tests/js-tests/src/ExtensionsTest/S9SpriteTest/S9SpriteTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,45 @@ var S9SpriteOpacityWithFadeActionsTest = S9SpriteTestDemo.extend({
}
});


var S9SpriteRenderingTypeToggleTest = S9SpriteTestDemo.extend({
_title:"Test Toggle Scale9Sprite RenderingType",

ctor:function() {
this._super();


var blocks = new ccui.Scale9Sprite('blocks9.png');
blocks.x = winSize.width / 2;
blocks.y = winSize.height / 2 + 50;

blocks.width = blocks.width * 2;


var button = this._button = new ccui.Button();
button.setTouchEnabled(true);
button.x = winSize.width / 2.0;
button.y = winSize.height / 2.0 - 50;
button.setTitleText("Toggle SIMPLE");
button.addTouchEventListener(function (sender, type) {
if(type === ccui.Widget.TOUCH_ENDED) {
if(blocks.getRenderingType() === ccui.Scale9Sprite.RenderingType.SLICED) {
blocks.setRenderingType(ccui.Scale9Sprite.RenderingType.SIMPLE);
button.setTitleText("Toggle SLICED");
} else {
blocks.setRenderingType(ccui.Scale9Sprite.RenderingType.SLICED);
button.setTitleText("Toggle SIMPLE");
}
}
} , this);

this.addChild(button);


this.addChild(blocks);
}
});

var S9SpriteTestScene = TestScene.extend({
runThisTest:function (num) {
sceneIdx = (num || num == 0) ? (num - 1) : -1;
Expand All @@ -617,7 +656,6 @@ var S9SpriteTestScene = TestScene.extend({
director.runScene(this);
}
});

//
// Flow control
//
Expand All @@ -637,7 +675,8 @@ var arrayOfS9SpriteTest = [
S9_TexturePacker,
S9SpriteActionTest,
S9SpriteColorOpacityTest,
S9SpriteOpacityWithFadeActionsTest
S9SpriteOpacityWithFadeActionsTest,
S9SpriteRenderingTypeToggleTest
];

var nextS9SpriteTest = function () {
Expand Down

0 comments on commit 163e730

Please sign in to comment.