Merge pull request #14348 from xiaofeng11/v3

Fixed actionNode position error bug
This commit is contained in:
pandamicro 2015-11-11 00:11:21 +08:00
commit 1ad877ee63
1 changed files with 14 additions and 0 deletions

View File

@ -26,6 +26,7 @@ THE SOFTWARE.
#include "cocostudio/CCActionFrameEasing.h" #include "cocostudio/CCActionFrameEasing.h"
#include "ui/UIWidget.h" #include "ui/UIWidget.h"
#include "ui/UIHelper.h" #include "ui/UIHelper.h"
#include "ui/UILayout.h"
#include "cocostudio/CocoLoader.h" #include "cocostudio/CocoLoader.h"
#include "base/ccUtils.h" #include "base/ccUtils.h"
@ -73,7 +74,14 @@ ActionNode::~ActionNode()
void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root) void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
{ {
Widget * rw = dynamic_cast<Widget *>(root);
if (nullptr == rw)
return;
setActionTag(DICTOOL->getIntValue_json(dic, "ActionTag")); setActionTag(DICTOOL->getIntValue_json(dic, "ActionTag"));
Widget* node = Helper::seekActionWidgetByActionTag(rw, getActionTag());
bool positionOffset = node && (nullptr == (dynamic_cast<Layout *>(node)));
int actionFrameCount = DICTOOL->getArrayCount_json(dic, "actionframelist"); int actionFrameCount = DICTOOL->getArrayCount_json(dic, "actionframelist");
for (int i=0; i<actionFrameCount; i++) for (int i=0; i<actionFrameCount; i++)
{ {
@ -97,6 +105,12 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
{ {
float positionX = DICTOOL->getFloatValue_json(actionFrameDic, "positionx"); float positionX = DICTOOL->getFloatValue_json(actionFrameDic, "positionx");
float positionY = DICTOOL->getFloatValue_json(actionFrameDic, "positiony"); 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(); ActionMoveFrame* actionFrame = new (std::nothrow) ActionMoveFrame();
actionFrame->setFrameIndex(frameInex); actionFrame->setFrameIndex(frameInex);
actionFrame->setEasingType(frameTweenType); actionFrame->setEasingType(frameTweenType);