Merge pull request #4555 from 2youyouo2/develop

fixed armature position not right
This commit is contained in:
James Chen 2013-12-19 05:05:25 -08:00
commit ec0bdf06af
2 changed files with 19 additions and 0 deletions

View File

@ -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;

View File

@ -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;