cocos2d-x3.0 Vector和Map简单使用

时间:2022-06-21 12:11:23
 Vector<Node*> vec;

    auto node1 = Node::create();
node1->setTag(1);
vec.pushBack(node1); auto node2 = Node::create();
node2->setTag(2);
vec.pushBack(node2); auto node3 = Node::create();
node3->setTag(3);
vec.insert(1, node3); Node* vecNode = static_cast<Node*>(vec.at(2));
log("vecNode->getTag() = %d",vecNode->getTag()); Map<std::string, Node*> map1 ;
map1.insert("name", node3); Node* tempNode = static_cast<Node*>(map1.at("name"));
log("tempNode->getTag() = %d",tempNode->getTag());