LoginSignup
2
1

More than 5 years have passed since last update.

【cocos2d-x】毎フレーム特定の関数を呼び出す

Last updated at Posted at 2014-05-21

時間をカウントアップさせたい時など、
毎フレーム特定の関数を呼び出したい時はスケジュールを設定する。

流れ

1,スケジュールをセット
2,スケジュールを解除

スケジュールをセット

CCLayerのinit()などでスケジュールをセット
※ヘッダーで関数は定義しておいて下さい。今回はvoid型のeveryFrameMethodとします。

bool クラス名::init()
{
    if (!CCLayer::init()) {
        return false;
    }

    //フレーム毎にmesureGameTime関数を呼び出す
    this -> schedule(schedule_selector(クラス名::everyFrameMethod));

    return true;
}

void クラス名::everyFrameMethod
{
    //毎フレーム行ないたい処理
}


スケジュールを解除

//スケジュールを解除したい場所で以下のコードを記入
this -> unschedule(schedule_selector(クラス名::everyFrameMethod));

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1