From 1f0c498bcb5c26d884275ea747eba33621b66879 Mon Sep 17 00:00:00 2001 From: XiaoFeng Date: Mon, 9 Nov 2015 19:45:17 +0800 Subject: [PATCH] Fixed actionNode position error bug --- cocos/editor-support/cocostudio/CCActionNode.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cocos/editor-support/cocostudio/CCActionNode.cpp b/cocos/editor-support/cocostudio/CCActionNode.cpp index f963a242f2..a879cd61f6 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.cpp +++ b/cocos/editor-support/cocostudio/CCActionNode.cpp @@ -26,6 +26,7 @@ THE SOFTWARE. #include "cocostudio/CCActionFrameEasing.h" #include "ui/UIWidget.h" #include "ui/UIHelper.h" +#include "ui/UILayout.h" #include "cocostudio/CocoLoader.h" #include "base/ccUtils.h" @@ -73,7 +74,14 @@ ActionNode::~ActionNode() void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root) { + Widget * rw = dynamic_cast(root); + if (nullptr == rw) + return; + setActionTag(DICTOOL->getIntValue_json(dic, "ActionTag")); + Widget* node = Helper::seekActionWidgetByActionTag(rw, getActionTag()); + bool positionOffset = node && (nullptr == (dynamic_cast(node))); + int actionFrameCount = DICTOOL->getArrayCount_json(dic, "actionframelist"); for (int i=0; igetFloatValue_json(actionFrameDic, "positionx"); float positionY = DICTOOL->getFloatValue_json(actionFrameDic, "positiony"); + if (positionOffset && (nullptr != node->getParent())) + { + Vec2 AnchorPointIn = node->getParent()->getAnchorPointInPoints(); + positionX += AnchorPointIn.x; + positionY += AnchorPointIn.y; + } ActionMoveFrame* actionFrame = new (std::nothrow) ActionMoveFrame(); actionFrame->setFrameIndex(frameInex); actionFrame->setEasingType(frameTweenType);