issue #2790: Reverts HelloWorldScene.cpp.

This commit is contained in:
James Chen 2013-12-04 17:51:53 +08:00
parent c9767b8ea0
commit 28eed3c8e0
1 changed files with 1 additions and 90 deletions

View File

@ -2,10 +2,10 @@
#include "AppMacros.h" #include "AppMacros.h"
#include "CCEventListenerTouch.h" #include "CCEventListenerTouch.h"
#include "CCVector.h"
USING_NS_CC; USING_NS_CC;
Scene* HelloWorld::scene() Scene* HelloWorld::scene()
{ {
// 'scene' is an autorelease object // 'scene' is an autorelease object
@ -21,94 +21,9 @@ Scene* HelloWorld::scene()
return scene; return scene;
} }
void showSprites(const Vector<Sprite*>& sprites)
{
log("container size = %ld", sprites.count());
for (auto& sp : sprites)
{
log("sp tag: %d, ref count = %d", sp->getTag(), sp->retainCount());
}
}
Vector<Sprite*> createAllSprites()
{
Vector<Sprite*> ret;
ret.addObject(Sprite::create());
ret.addObject(Sprite::create());
return ret;
}
// on "init" you need to initialize your instance // on "init" you need to initialize your instance
bool HelloWorld::init() bool HelloWorld::init()
{ {
Vector<Sprite*> container;
for (int i = 0; i < 10; ++i)
{
auto sp = Sprite::create();
sp->setTag(i);
container.addObject(sp);
}
//
// showSprites(container);
//
// Vector<Sprite*> containerCopy = container;
//
// showSprites(containerCopy);
//
// containerCopy = container;
//
// showSprites(containerCopy);
// Vector<Sprite*> moveVector(createAllSprites());
// showSprites(moveVector);
//
// CCLOG("------------- 2 ----------");
// moveVector = createAllSprites();
// showSprites(moveVector);
//
// CCLOG("------------- 3 ----------");
// Vector<Sprite*> aaa;
// aaa.addObject(Sprite::create());
// moveVector = aaa;
// showSprites(moveVector);
log("size of Vector = %ld", sizeof(Vector<Sprite*>));
Map<std::string, Sprite*> map;
map.setObject(Sprite::create(), "1");
map.setObject(Sprite::create(), "2");
map.setObject(Sprite::create(), "3");
auto showMap = [](const Map<std::string, Sprite*>& map)
{
for (auto iter = map.begin(); iter != map.end(); ++iter)
{
log("key = %s, value = %p, ref = %d", iter->first.c_str(), iter->second, iter->second ? iter->second->retainCount() : 0);
}
};
showMap(map);
// auto iter = std::find(map.begin(), map.end(), std::string("111"));
// if (iter != map.end())
// {
// log("found!");
// }
// else
// {
// log("not found!");
// }
// map["111"];
// log("key[1]=%p", map["1"]);
// log("----------------------");
// map["11"]->setPosition(Point(100, 100));
showMap(map);
////////////////////////////// //////////////////////////////
// 1. super init first // 1. super init first
if ( !Layer::init() ) if ( !Layer::init() )
@ -160,10 +75,6 @@ bool HelloWorld::init()
// add the sprite as a child to this layer // add the sprite as a child to this layer
this->addChild(sprite); this->addChild(sprite);
this->getChildren().forEach([](Node* node){
log("node = %p, name = %s", node, typeid(*node).name());
});
return true; return true;
} }