diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 62517e1604..d4a1342e29 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -352,6 +352,11 @@ const Vec2& Armature::getAnchorPointInPoints() const return _realAnchorPointInPoints; } +const Vec2& Armature::getOffsetPoints() const +{ + return _offsetPoint; +} + void Armature::setAnimation(ArmatureAnimation *animation) { _animation = animation; diff --git a/cocos/editor-support/cocostudio/CCArmature.h b/cocos/editor-support/cocostudio/CCArmature.h index 3ce0a58ac7..da1e9792e4 100644 --- a/cocos/editor-support/cocostudio/CCArmature.h +++ b/cocos/editor-support/cocostudio/CCArmature.h @@ -184,6 +184,7 @@ public: virtual void updateOffsetPoint(); virtual void setAnchorPoint(const cocos2d::Vec2& point) override; virtual const cocos2d::Vec2& getAnchorPointInPoints() const override; + virtual const cocos2d::Vec2& getOffsetPoints() const; virtual void setAnimation(ArmatureAnimation *animation); virtual ArmatureAnimation *getAnimation() const; diff --git a/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp index eabfb21ac0..4661c87209 100644 --- a/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp @@ -407,6 +407,61 @@ static void extendBone(lua_State* L) lua_pop(L, 1); } +static int lua_cocos2dx_extension_Armature_getOffsetPoints(lua_State* L) +{ + int argc = 0; + cocostudio::Armature* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(L,1,"ccs.Armature",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocostudio::Armature*)tolua_tousertype(L,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(L, "invalid 'cobj' in function 'lua_cocos2dx_extension_Armature_getOffsetPoints'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(L)-1; + if (argc == 0) + { + if(!ok) + return 0; + const cocos2d::Vec2& ret = cobj->getOffsetPoints(); + vec2_to_luaval(L, ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getOffsetPoints", argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(L,"#ferror in function 'lua_cocos2dx_extension_Armature_getOffsetPoints'.",&tolua_err); +#endif + + return 0; +} + +static void extendArmature(lua_State* L) +{ + lua_pushstring(L, "ccs.Armature"); + lua_rawget(L, LUA_REGISTRYINDEX); + if (lua_istable(L,-1)) + { + tolua_function(L, "getOffsetPoints", lua_cocos2dx_extension_Armature_getOffsetPoints); + } + lua_pop(L, 1); +} int lua_cocos2dx_studio_NodeReader_getInstance(lua_State* L) { int argc = 0; @@ -607,6 +662,7 @@ int register_all_cocos2dx_coco_studio_manual(lua_State* L) { if (nullptr == L) return 0; + extendArmature(L); extendArmatureAnimation(L); extendArmatureDataManager(L); extendBone(L);