Interact two sprite actions?

Interact two sprite actions?
0

#1

I want to interact two sprite actions. I guess sequence not supporting different sprites.

I need;
After completing sprite A action(s) I want to start B sprite action

how can I make it?


#2

You could use Sequence
Example:
scene->runAction(Sequence::create(MoveTo(...), MoveTo(...), NULL));


#3

Use Sequence and CallFunc
https://docs.cocos2d-x.org/cocos2d-x/en/actions/sequences.html


#4

examples describes only one sprite sequence, I want sequence for different sprites. It seems only solution is calculating duration of sprite 1 actions and delay sprite 2

after sprite1 action > run sprite 2 action


#5

Did you look at CallFunc ?


#6

running sprite B action as CallFunc in sprite A sequence I will try this


#7

Running Ease action in sequence within CallFunc crashes. without Ease it works


#8

Show your code please


#9
		auto toppercentanim = CallFunc::create([&](){
			auto scalepercent = ScaleTo::create(0.4f, 1.5f);
			auto percentease = EaseElasticOut::create( scalepercent );
			auto scalepercent2 = ScaleTo::create(0.2f, 1.0f);
			auto seq_   = Sequence::create(percentease, scalepercent2 );
			spriteB->runAction(seq_);
		}); 

auto seq   = Sequence::create(easeAction, scale2, moveby, spa, setPercent, toppercentanim, nullptr);
spriteA->runAction(seq);

If i remove ease in CallFunc still not working, it works only if i remove sequence in CallFunc


#10

You forgot to add nullptr at the end


#11

Omg!, thanks It works


closed #12

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.