mirror of https://github.com/axmolengine/axmol.git
Merge pull request #156 from pandamicro/compJSB
Fix jsbinding calls for CCComponent
This commit is contained in:
commit
28f3d19db8
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue