From 70da0bab47af60c619345a9d45aed7efdd0b2d6b Mon Sep 17 00:00:00 2001 From: linguofeng Date: Sun, 16 Mar 2014 22:01:54 +0800 Subject: [PATCH] update --- _posts/2014-03-16-cocos2d-x-3-0.textile | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 _posts/2014-03-16-cocos2d-x-3-0.textile diff --git a/_posts/2014-03-16-cocos2d-x-3-0.textile b/_posts/2014-03-16-cocos2d-x-3-0.textile new file mode 100644 index 0000000..30340f5 --- /dev/null +++ b/_posts/2014-03-16-cocos2d-x-3-0.textile @@ -0,0 +1,40 @@ +--- +layout: post +title: Cocos2d-x 3.0 +description: Cocos2d-x 3.0之新容器 +categories: [archive] +tags: [cocos2d-x] +--- + +
+

今天试着把代码升级至3.0,发现之前的CCArray的容器都变了,现在是使用Vector与Map,简单用法

+
+cocos2d::Vector sprites;
+
+auto sprite1 = Sprite::create("hello.png");
+auto sprite2 = Sprite::create("hello.png");
+auto sprite3 = Sprite::create("hello.png");
+auto sprite4 = Sprite::create("hello.png");
+
+sprites.push_back(sprite1)
+sprites.push_back(sprite2)
+sprites.push_back(sprite3)
+sprites.push_back(sprite4)
+
+

@sprites@ 内存管理是由编译器自动处理的,不要使用new来申请堆空间。

+
+cocos2d::Map nodes;
+
+auto node1 = Layer::create():
+auto node2 = Layer::create():
+auto node3 = Layer::create():
+auto node4 = Layer::create():
+
+nodes.insert("node_1", node1)
+nodes.insert("node_2", node1)
+nodes.insert("node_3", node1)
+nodes.insert("node_4", node1)
+
+

参考:http://cocos2d-x.org/docs/manual/framework/native/data-structure/v3/vector/zh

+

http://cocos2d-x.org/docs/manual/framework/native/data-structure/v3/map/zh

+
-- 2.11.4.GIT