LoginSignup
0
0

More than 5 years have passed since last update.

cocos2d-x の Node系オブジェクトに resume() という名前の関数を定義するとEventListenerなどが動作しなくなる

Posted at

タイトルの通りです。以下の様にresume()という関数を定義します。

class GameScene : public Layer
{
public:
    void resume();
}

void GameScene::resume()
{
    // resume って名前の関数はデフォルトのNodeに定義されているので、それをブロックするとおかしくなる
    CCLOG("どっかから呼ばれてくる。 BreakPoint指定するとよくわかる");
}

すると、本来であれば CCNode.cpp で定義されている Node::resume() で行われるはずの処理が行われず、EventListenerなどが動作しなくなります。

まとめ

  • 継承したクラスに関数を追加するときは、オーバーライドしちゃってないか気をつけよう
  • overrideキーワードなどで明示的にオーバーライドしていることを示さないとコンパイルエラー出る言語が増えてきたので未来はきっと明るい
0
0
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
0
0