Cocos2d-x 3.0 Schedule Error2276

时间:2017-05-31 17:33:00

标签: c++ cocos2d-x

我收到此错误:

  

'&':对绑定成员函数表达式的非法操作

在这一行:

this->schedule(schedule_selector(TimerMethod), 0.01);

我不知道为什么,因为没有"&"代码中的字符。

1 个答案:

答案 0 :(得分:0)

ClassName::methodName micro。

中传递类名为schedule_selector的方法名称

假设Xyz是Layer的孩子的任何类的名称。

class Xyz : public Layer {

   public:

   virtual bool init();
   void TimerMethod(float dt) {

   }
}

以这种方式在Layer init()方法中进行调度:

bool Xyz::init(){

     if(!Layer::init())
          return false;

    this->schedule(schedule_selector(Xyz::TimerMethod), 0.01);
    return true;
}