Skip to content

Commit

Permalink
Add TransitionActionType.Text and TransitionActionType.Icon
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoguzhu committed Sep 7, 2018
1 parent 4612ff3 commit 3c04834
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
2 changes: 2 additions & 0 deletions libfairygui/Classes/FieldTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ enum class TransitionActionType
Shake,
ColorFilter,
Skew,
Text,
Icon,
Unknown
};

Expand Down
38 changes: 37 additions & 1 deletion libfairygui/Classes/Transition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class TValue_Shake
cocos2d::Vec2 offset;
};

class TValue_Text
{
public:
std::string text;
};

class TValue
{
public:
Expand Down Expand Up @@ -199,6 +205,11 @@ TransitionItem::TransitionItem(TransitionActionType aType) :
value = new TValue_Visible();
break;

case TransitionActionType::Text:
case TransitionActionType::Icon:
value = new TValue_Text();
break;

default:
value = nullptr;
break;
Expand Down Expand Up @@ -562,6 +573,11 @@ void Transition::setValue(const std::string & label, const ValueVector& values)
tvalue->f4 = values[3].asFloat();
break;
}

case TransitionActionType::Text:
case TransitionActionType::Icon:
((TValue_Text*)value)->text = values[0].asString();
break;
}
}
}
Expand Down Expand Up @@ -988,6 +1004,13 @@ void Transition::onTweenStart(GTweener* tweener)
if (!startValue->b2)
startValue->f2 = item->target->getY();
}
else
{
if (!startValue->b1)
startValue->f1 = item->target->getX() - _ownerBaseX;
if (!startValue->b2)
startValue->f2 = item->target->getY() - _ownerBaseY;
}
}
else
{
Expand Down Expand Up @@ -1230,9 +1253,16 @@ void Transition::applyValue(TransitionItem* item)
break;
}


case TransitionActionType::ColorFilter:
break;

case TransitionActionType::Text:
item->target->setText(((TValue_Text*)item->value)->text);
break;

case TransitionActionType::Icon:
item->target->setIcon(((TValue_Text*)item->value)->text);
break;
}

item->target->_gearLocked = false;
Expand Down Expand Up @@ -1374,6 +1404,12 @@ void Transition::decodeValue(TransitionItem* item, ByteBuffer * buffer, void* va
tvalue->f4 = buffer->ReadFloat();
break;
}

case TransitionActionType::Text:
case TransitionActionType::Icon:
((TValue_Text*)value)->text = buffer->ReadS();
break;

default:
break;
}
Expand Down
12 changes: 6 additions & 6 deletions libfairygui/Classes/tween/TweenPropType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void TweenPropTypeUtils::setProps(GObject * target, TweenPropType propType, cons
break;

case TweenPropType::Y:
g->setY(value.y);
g->setY(value.x);
break;

case TweenPropType::Position:
Expand All @@ -31,7 +31,7 @@ void TweenPropTypeUtils::setProps(GObject * target, TweenPropType propType, cons
break;

case TweenPropType::Height:
g->setHeight(value.y);
g->setHeight(value.x);
break;

case TweenPropType::Size:
Expand All @@ -43,7 +43,7 @@ void TweenPropTypeUtils::setProps(GObject * target, TweenPropType propType, cons
break;

case TweenPropType::ScaleY:
g->setScaleY(value.y);
g->setScaleY(value.x);
break;

case TweenPropType::Scale:
Expand Down Expand Up @@ -77,7 +77,7 @@ void TweenPropTypeUtils::setProps(cocos2d::Node * target, TweenPropType propType
break;

case TweenPropType::Y:
g->setY(value.y);
g->setY(value.x);
break;

case TweenPropType::Position:
Expand All @@ -89,7 +89,7 @@ void TweenPropTypeUtils::setProps(cocos2d::Node * target, TweenPropType propType
break;

case TweenPropType::Height:
g->setHeight(value.y);
g->setHeight(value.x);
break;

case TweenPropType::Size:
Expand All @@ -101,7 +101,7 @@ void TweenPropTypeUtils::setProps(cocos2d::Node * target, TweenPropType propType
break;

case TweenPropType::ScaleY:
g->setScaleY(value.y);
g->setScaleY(value.x);
break;

case TweenPropType::Scale:
Expand Down

0 comments on commit 3c04834

Please sign in to comment.