diff --git a/cocos/2d/CCComponent.cpp b/cocos/2d/CCComponent.cpp index 5b7049e6f7..6bb111830b 100644 --- a/cocos/2d/CCComponent.cpp +++ b/cocos/2d/CCComponent.cpp @@ -74,8 +74,7 @@ void Component::onEnter() #if CC_ENABLE_SCRIPT_BINDING if (_scriptType == kScriptTypeJavascript) { - if (sendComponentEventToJS(this, kComponentOnEnter)) - return; + sendComponentEventToJS(this, kComponentOnEnter); } #endif } @@ -85,8 +84,7 @@ void Component::onExit() #if CC_ENABLE_SCRIPT_BINDING if (_scriptType == kScriptTypeJavascript) { - if (sendComponentEventToJS(this, kComponentOnExit)) - return; + sendComponentEventToJS(this, kComponentOnExit); } #endif } @@ -96,8 +94,7 @@ void Component::onAdd() #if CC_ENABLE_SCRIPT_BINDING if (_scriptType == kScriptTypeJavascript) { - if (sendComponentEventToJS(this, kComponentOnAdd)) - return; + sendComponentEventToJS(this, kComponentOnAdd); } #endif } @@ -107,8 +104,7 @@ void Component::onRemove() #if CC_ENABLE_SCRIPT_BINDING if (_scriptType == kScriptTypeJavascript) { - if (sendComponentEventToJS(this, kComponentOnRemove)) - return; + sendComponentEventToJS(this, kComponentOnRemove); } #endif } @@ -118,8 +114,7 @@ void Component::update(float delta) #if CC_ENABLE_SCRIPT_BINDING if (_scriptType == kScriptTypeJavascript) { - if (sendComponentEventToJS(this, kComponentOnUpdate)) - return; + sendComponentEventToJS(this, kComponentOnUpdate); } #endif } diff --git a/cocos/2d/CCLabelTextFormatter.cpp b/cocos/2d/CCLabelTextFormatter.cpp index a7e94cee3f..a790923e91 100644 --- a/cocos/2d/CCLabelTextFormatter.cpp +++ b/cocos/2d/CCLabelTextFormatter.cpp @@ -407,7 +407,7 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel) } } - letterPosition.x = (nextFontPositionX + charXOffset + kernings[i]) / contentScaleFactor; + letterPosition.x = (nextFontPositionX + charXOffset) / contentScaleFactor; letterPosition.y = (nextFontPositionY - charYOffset) / contentScaleFactor; if( theLabel->recordLetterInfo(letterPosition, tempDefinition, i) == false) @@ -417,6 +417,10 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel) } nextFontPositionX += charAdvance + theLabel->_additionalKerning; + if (i < stringLen - 1) + { + nextFontPositionX += kernings[i + 1]; + } auto letterRight = letterPosition.x + tempDefinition.width; if (longestLine < letterRight) diff --git a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp index 05e1fe2528..5f12532efc 100644 --- a/cocos/scripting/js-bindings/manual/ScriptingCore.cpp +++ b/cocos/scripting/js-bindings/manual/ScriptingCore.cpp @@ -1058,7 +1058,21 @@ int ScriptingCore::handleComponentEvent(void* data) JS::RootedValue retval(_cx); jsval dataVal = INT_TO_JSVAL(1); - if (action == kComponentOnEnter) + if (action == kComponentOnAdd) + { + if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onAdd", js_cocos2dx_Component_onEnter)) + { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onAdd", 1, &dataVal, &retval); + } + } + else if (action == kComponentOnRemove) + { + if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onRemove", js_cocos2dx_Component_onExit)) + { + ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onRemove", 1, &dataVal, &retval); + } + } + else if (action == kComponentOnEnter) { if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onEnter", js_cocos2dx_Component_onEnter)) {