偶然想到要在函数内部使用lambda递归调用,以下是可行的写法,可参考

 

 1     std::function<void(Node * container,const BlendFunc &blendFunc)> blendFucCall;
 2     
 3     blendFucCall = [&blendFucCall](Node * container,const BlendFunc &blendFunc)
 4     {
 5         for ( auto child : container->getChildren())
 6         {
 7             auto sp = dynamic_cast<Sprite*>(child);
 8             if (sp)
 9             {
10                 sp->setBlendFunc(blendFunc);
11             }
12             else
13             {
14                 blendFucCall(child,blendFunc);
15             }
16         }
17     };
18     blendFucCall(this,blendFunc);

 

相关文章:

  • 2021-10-08
  • 2022-02-09
  • 2021-06-14
  • 2022-02-20
  • 2021-09-01
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-19
  • 2022-12-23
  • 2021-06-27
  • 2022-02-03
  • 2022-02-15
  • 2022-01-07
相关资源
相似解决方案