diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 7ce9d7aceb..57009a0bb7 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -338,6 +338,22 @@ void Armature::updateOffsetPoint() } } +void Armature::setAnchorPoint(const Point& point) +{ + if( ! point.equals(_anchorPoint)) + { + _anchorPoint = point; + _anchorPointInPoints = Point(_contentSize.width * _anchorPoint.x - _offsetPoint.x, _contentSize.height * _anchorPoint.y - _offsetPoint.y); + _realAnchorPointInPoints = Point(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y); + _transformDirty = _inverseDirty = true; + } +} + +const Point& Armature::getAnchorPointInPoints() const +{ + return _realAnchorPointInPoints; +} + void Armature::setAnimation(ArmatureAnimation *animation) { _animation = animation; diff --git a/cocos/editor-support/cocostudio/CCArmature.h b/cocos/editor-support/cocostudio/CCArmature.h index b16b1d0056..1b5cbc64c6 100644 --- a/cocos/editor-support/cocostudio/CCArmature.h +++ b/cocos/editor-support/cocostudio/CCArmature.h @@ -178,6 +178,8 @@ public: * Set contentsize and Calculate anchor point. */ virtual void updateOffsetPoint(); + virtual void setAnchorPoint(const cocos2d::Point& point) override; + virtual const cocos2d::Point& getAnchorPointInPoints() const override; virtual void setAnimation(ArmatureAnimation *animation); virtual ArmatureAnimation *getAnimation() const; @@ -265,6 +267,7 @@ protected: cocos2d::BlendFunc _blendFunc; //! It's required for CCTextureProtocol inheritance cocos2d::Point _offsetPoint; + cocos2d::Point _realAnchorPointInPoints; ArmatureAnimation *_animation;