[cocos2dx入門] schedule(ルート)の利用方法
参考コード:
#include
#include
using namespace std;
class Ref
{
protected:
Ref(){isLoop = false;}
virtual void update(){cout<< “スーパーループ" << endl;} bool isLoop; public: void unScheduleUpdate(){isLoop = false;} void ScheduleUpdate(){isLoop = true;} void mainLoop(){if (isLoop)this->update();}
};
class myClass :public Ref
{
public:
virtual void update(){cout << “このループ" << endl;} }; int main(int argc, char* argv[]) { Ref*ref = new myClass; ref->ScheduleUpdate();
for (;;)
{
cout << “loop" << endl; Sleep(500); ref->mainLoop();
ref->unScheduleUpdate();
}
return(0);