mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3343 from dabingnn/Iss2423-TargetAction-Reverse
Iss2423 target action reverse
This commit is contained in:
commit
077acb7814
|
@ -2201,8 +2201,11 @@ TargetedAction* TargetedAction::clone() const
|
|||
|
||||
TargetedAction* TargetedAction::reverse(void) const
|
||||
{
|
||||
// no reverse for this action, just clone it
|
||||
return this->clone();
|
||||
// just reverse the internal action
|
||||
auto a = new TargetedAction();
|
||||
a->initWithTarget(_forcedTarget, _action->reverse());
|
||||
a->autorelease();
|
||||
return a;
|
||||
}
|
||||
|
||||
void TargetedAction::startWithTarget(Node *target)
|
||||
|
|
|
@ -39,6 +39,7 @@ static std::function<Layer*()> createFunctions[] = {
|
|||
CL(ActionOrbit),
|
||||
CL(ActionFollow),
|
||||
CL(ActionTargeted),
|
||||
CL(ActionTargetedReverse),
|
||||
CL(ActionMoveStacked),
|
||||
CL(ActionMoveJumpStacked),
|
||||
CL(ActionMoveBezierStacked),
|
||||
|
@ -1335,6 +1336,37 @@ std::string ActionTargeted::subtitle()
|
|||
return "Action that runs on another target. Useful for sequences";
|
||||
}
|
||||
|
||||
|
||||
void ActionTargetedReverse::onEnter()
|
||||
{
|
||||
ActionsDemo::onEnter();
|
||||
centerSprites(2);
|
||||
|
||||
|
||||
auto jump1 = JumpBy::create(2,Point::ZERO,100,3);
|
||||
auto jump2 = jump1->clone();
|
||||
auto rot1 = RotateBy::create(1, 360);
|
||||
auto rot2 = rot1->clone();
|
||||
|
||||
auto t1 = TargetedAction::create(_kathia, jump2);
|
||||
auto t2 = TargetedAction::create(_kathia, rot2);
|
||||
|
||||
auto seq = Sequence::create(jump1, t1->reverse(), rot1, t2->reverse(), NULL);
|
||||
auto always = RepeatForever::create(seq);
|
||||
|
||||
_tamara->runAction(always);
|
||||
}
|
||||
|
||||
std::string ActionTargetedReverse::title()
|
||||
{
|
||||
return "ActionTargetedReverse";
|
||||
}
|
||||
|
||||
std::string ActionTargetedReverse::subtitle()
|
||||
{
|
||||
return "Action that runs reversely on another target. Useful for sequences";
|
||||
}
|
||||
|
||||
//#pragma mark - ActionStacked
|
||||
|
||||
void ActionStacked::onEnter()
|
||||
|
|
|
@ -289,6 +289,14 @@ public:
|
|||
virtual std::string subtitle();
|
||||
};
|
||||
|
||||
class ActionTargetedReverse : public ActionsDemo
|
||||
{
|
||||
public:
|
||||
virtual void onEnter();
|
||||
virtual std::string title();
|
||||
virtual std::string subtitle();
|
||||
};
|
||||
|
||||
class ActionStacked : public ActionsDemo
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue