auto noder = Node::create();
auto delayer = DelayTime::create(5.0);
auto seq = Sequence::create(delayer, TeamCut(this), nullptr);
noder->runAction(seq);
When i run the code my sprite spawned right now, not 5 seconds later. Where is the problem ?
Because my code doesn’t work. I spawn my sprite at layer(-5) and than after the delay i change my sprites layer to 5. Therefore i need to write setLocalZOrder in CallFunc.
Sequence needs objects of type FiniteTimeAction to be passed to it, so passing it your own method directly is going to cause problems. You are on the right track though, as you do need to use CallFunc (which is a FiniteTimeAction).
auto seq = Sequence::create(delayer, CallFunc::create([this]() {
TeamCut(this);
}), nullptr);
Problem Solved. Thanks @R101 . After your advice i gave 2 errors. @dimon4eg solved first one. The second one vas C2512 error. To solve this error i modified your advice:
auto seq = Sequence::create(delayer, CallFunc::create([this]() { teamCut = new TeamCut(this);} ), nullptr);