C++
openFrameworks

C++でのsetChildIndexの実装例

More than 3 years have passed since last update.
vector<flash::DisplayObject*> children;

void DisplayObjectContainer::setChildIndex(flash::DisplayObject* child, const int& index) {
    if(index < 0 || index > children.size() - 1) throw "DisplayObjectContainer::setChildIndex\n";

    for(int i = 0; i < children.size(); i++) {
        if(children[i] == child){
            children.erase(children.begin() + i);
            children.insert(children.begin() + index, child);
            return;
        }
    }
}