LoginSignup
2
2

More than 5 years have passed since last update.

C++でのremoveChildの実装例

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

flash::DisplayObject* DisplayObjectContainer::removeChild(flash::DisplayObject* child) {
    for(int i = 0; i < children.size(); i++) {
        if(children[i] == child) {
            //ステージとの参照を切る
            child->stage(NULL); 
            //親コンテナとの参照を切る
            child->parent(NULL);
            //配列から削除
            children.erase(children.begin() + i);
            return child;
        }
    }

    //対象の子がなかったらエラー
    throw "DisplayObjectContainer::removeChild\n";
}
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