LoginSignup
2
2

More than 5 years have passed since last update.

C++でのremoveChildAtの実装例

Last updated at Posted at 2014-03-02
vector<flash::DisplayObject*> children;

flash::DisplayObject* DisplayObjectContainer::removeChildAt(const int& index) {
    //対象の子がなかったらエラー
    if(index < 0 || index > children.size() - 1) throw "DisplayObjectContainer::removeChildAt\n";

    DisplayObject* child = children[index];
    //ステージとの参照を切る
    child->stage(NULL);
    //親コンテナとの参照を切る
    child->parent(NULL);
    //配列から削除
    children.erase(children.begin() + index);

    return child;
}
2
2
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
2