c++ - Cocos2d-x Remove sprites in specified rectangular area -
i'm using cocos2d-x , i'm looking efficient way remove sprites under rectangular region. for example if have lot of random located sprites on scene , want remove of them if belong rectangular (x1, y1),(x2, y2), need do? i see there 2 ways remove sprite scene: this->removechildbytag(tag); or sprite->removefromparent(); so these methods seems need somehow find sprites located inside area , after delete them. but efficient way it? thanks! the way using default cocos functionality iterate on each child detect overlapping , remove nodes match criteria. removefromparent() removechildbytag() invoke parent->removechild(this); . , removechild() uses std::find in vector of child nodes. complexity o(n). first step of optimization use detachchild utilizes index of child. but if not fast enough recommend using special data structure search overlapping interval tree.