当前位置: 首页>>代码示例>>C++>>正文


C++ setTag函数代码示例

本文整理汇总了C++中setTag函数的典型用法代码示例。如果您正苦于以下问题:C++ setTag函数的具体用法?C++ setTag怎么用?C++ setTag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setTag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setColor

void Raquet::setColor(ccColor3B color, float duration) {
    auto colorize = CCTintTo::create(duration, color.r, color.g, color.b);
    colorize->setTag(colorizeActionTag);
    sprite->stopActionByTag(colorizeActionTag);
    sprite->runAction(colorize);
}
开发者ID:win2l,项目名称:cocos2d-x-arkanoid,代码行数:6,代码来源:Raquet.cpp

示例2: Value

Node* StageSelect::getItemNode(int i)
{
    auto item = Node::create();
    Sprite* item_bk = nullptr;
    if(i<=fake_overstage)
        item_bk = Sprite::createWithSpriteFrameName("bt_mission_0.png");
    else
        item_bk = Sprite::createWithSpriteFrameName("bt_mission_1.png");
    item->setAnchorPoint(Point::ANCHOR_MIDDLE);
    item_bk->setPosition(Point(_cellSize.width/2,_cellSize.height/2));
    item_bk->setTag(20);
    item->addChild(item_bk);
    
    auto item_hl = Sprite::createWithSpriteFrameName("bt_mission_3.png");
    item_hl->setAnchorPoint(Point::ANCHOR_MIDDLE);
    item_hl->setPosition(Point(_cellSize.width/2,_cellSize.height/2));
    item_hl->setTag(30);
    item_hl->setVisible(false);
    item->addChild(item_hl);
    
    if(i == _selectItem)
        item_hl->setVisible(true);
    else
        item_hl->setVisible(false);
    
    if(_noTouch && i==_selectItem)
        item_hl->setVisible(true);
    
    std::string stage_text_str = s_gameStrings.mainMenu->stagetext + " - " + Value(i+1).asString();
    auto stage_text = TextSprite::create(stage_text_str,GameConfig::defaultFontName,GameConfig::defaultFontSize);
    if(i<fake_overstage)
        stage_text->setColor(Color3B(230,230,230));
    else
        stage_text->setColor(Color3B(80,80,80));
    
    if (_noTouch && i == _selectItem) {
        stage_text->setColor(DIY_COLOR_BLUE5);
    }
    stage_text->setAnchorPoint(Point::ANCHOR_MIDDLE);
    stage_text->setPosition(Point(_cellSize.width/2,_cellSize.height/2));
    stage_text->setTag(40);
    item->addChild(stage_text);
    
    auto sp_new = Sprite::createWithSpriteFrameName("icon_new.png");
    sp_new->setAnchorPoint(Point::ANCHOR_MIDDLE);
    sp_new->setPosition(Point(_cellSize.width/2+150,_cellSize.height/2));
    sp_new->setTag(50);
    sp_new->setVisible(false);
    item->addChild(sp_new);
    
    if (fake_overstage == i && s_playerConfig.overstage<50) {
        sp_new->setVisible(true);
    }
    

    auto ball = RotateBall::createWithIdx(i);
    ball->setAnchorPoint(Point::ANCHOR_MIDDLE);
    ball->setPosition(100, 50);
    ball->setTag(60);
    item->addChild(ball);
    ball->setRotate(true);
    
    auto ball_mask = Sprite::createWithSpriteFrameName("icon_planet_mask.png");
    ball_mask->setOpacity(120);
    ball_mask->setScale(0.8f);
    ball_mask->setAnchorPoint(Point::ANCHOR_MIDDLE);
    ball_mask->setPosition(100, 50);
    ball_mask->setTag(70);
    item->addChild(ball_mask);
    if(i<=fake_overstage)
        ball_mask->setVisible(false);
    else
        ball_mask->setVisible(true);
    
    
    return item;
}
开发者ID:jonesgithub,项目名称:BlackWings,代码行数:77,代码来源:StageSelect.cpp

示例3: generateTestFunctions

void KeyboardEventDispatchingPerfTest::generateTestFunctions()
{
    TestFunction testFunctions[] = {
        { "keyboard-scenegraph",    [=](){
            auto dispatcher = Director::getInstance()->getEventDispatcher();
            if (_quantityOfNodes != _lastRenderedCount)
            {
                auto listener = EventListenerKeyboard::create();
                listener->onKeyPressed = [](EventKeyboard::KeyCode keyCode, Event* event){};
                listener->onKeyReleased = [](EventKeyboard::KeyCode keyCode, Event* event){};
                
                // Create new nodes listen to keyboard event
                for (int i = 0; i < this->_quantityOfNodes; ++i)
                {
                    auto node = Node::create();
                    node->setTag(1000 + i);
                    this->addChild(node);
                    this->_nodes.push_back(node);
                    dispatcher->addEventListenerWithSceneGraphPriority(listener->clone(), node);
                }
                
                _lastRenderedCount = _quantityOfNodes;
            }
            
            EventKeyboard event(EventKeyboard::KeyCode::KEY_RETURN, true);
            
            CC_PROFILER_START(this->profilerName());
            dispatcher->dispatchEvent(&event);
            CC_PROFILER_STOP(this->profilerName());
        } } ,
        
        { "keyboard-fixed",    [=](){
            auto dispatcher = Director::getInstance()->getEventDispatcher();
            if (_quantityOfNodes != _lastRenderedCount)
            {
                auto listener = EventListenerKeyboard::create();
                listener->onKeyPressed = [](EventKeyboard::KeyCode keyCode, Event* event){};
                listener->onKeyReleased = [](EventKeyboard::KeyCode keyCode, Event* event){};
                
                for (int i = 0; i < this->_quantityOfNodes; ++i)
                {
                    auto l = listener->clone();
                    this->_fixedPriorityListeners.push_back(l);
                    dispatcher->addEventListenerWithFixedPriority(l, i+1);
                }
                
                _lastRenderedCount = _quantityOfNodes;
            }
            
            EventKeyboard event(EventKeyboard::KeyCode::KEY_RETURN, true);
            
            CC_PROFILER_START(this->profilerName());
            dispatcher->dispatchEvent(&event);
            CC_PROFILER_STOP(this->profilerName());
        } } ,
    };
    
    for (const auto& func : testFunctions)
    {
        _testFunctions.push_back(func);
    }
}
开发者ID:TinySlik,项目名称:cocos2d-x-3.x-Qt,代码行数:62,代码来源:PerformanceEventDispatcherTest.cpp

示例4: CC_CALLBACK_2

LabelFNTMultiLineAlignment::LabelFNTMultiLineAlignment()
{
    auto listener = EventListenerTouchAllAtOnce::create();
    listener->onTouchesBegan = CC_CALLBACK_2(LabelFNTMultiLineAlignment::onTouchesBegan, this);
    listener->onTouchesMoved = CC_CALLBACK_2(LabelFNTMultiLineAlignment::onTouchesMoved, this);
    listener->onTouchesEnded = CC_CALLBACK_2(LabelFNTMultiLineAlignment::onTouchesEnded, this);
    
    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
    // ask director the the window size
    auto size = Director::getInstance()->getWinSize();

    // create and initialize a Label
    this->_labelShouldRetain = Label::createWithBMFont("fonts/markerFelt.fnt", LongSentencesExample, TextHAlignment::CENTER, size.width/1.5);
    this->_labelShouldRetain->setAnchorPoint(Point::ANCHOR_MIDDLE);
    this->_labelShouldRetain->retain();

    this->_arrowsBarShouldRetain = Sprite::create("Images/arrowsBar.png");
    this->_arrowsBarShouldRetain->retain();
    this->_arrowsShouldRetain = Sprite::create("Images/arrows.png");
    this->_arrowsShouldRetain->retain();

    MenuItemFont::setFontSize(20);
    auto longSentences = MenuItemFont::create("Long Flowing Sentences", CC_CALLBACK_1(LabelFNTMultiLineAlignment::stringChanged, this));
    auto lineBreaks    = MenuItemFont::create("Short Sentences With Intentional Line Breaks", CC_CALLBACK_1(LabelFNTMultiLineAlignment::stringChanged, this));
    auto mixed         = MenuItemFont::create("Long Sentences Mixed With Intentional Line Breaks", CC_CALLBACK_1(LabelFNTMultiLineAlignment::stringChanged, this));
    auto stringMenu    = Menu::create(longSentences, lineBreaks, mixed, NULL);
    stringMenu->alignItemsVertically();

    longSentences->setColor(Color3B::RED);
    _lastSentenceItem = longSentences;
    longSentences->setTag(LongSentences);
    lineBreaks->setTag(LineBreaks);
    mixed->setTag(Mixed);

    MenuItemFont::setFontSize(30);

    auto left = MenuItemFont::create("Left", CC_CALLBACK_1(LabelFNTMultiLineAlignment::alignmentChanged, this));
    auto center = MenuItemFont::create("Center", CC_CALLBACK_1(LabelFNTMultiLineAlignment::alignmentChanged, this));
    auto right = MenuItemFont::create("Right", CC_CALLBACK_1(LabelFNTMultiLineAlignment::alignmentChanged, this));
    auto alignmentMenu = Menu::create(left, center, right, NULL);
    alignmentMenu->alignItemsHorizontallyWithPadding(alignmentItemPadding);

    center->setColor(Color3B::RED);
    _lastAlignmentItem = center;
    left->setTag(LeftAlign);
    center->setTag(CenterAlign);
    right->setTag(RightAlign);

    // position the label on the center of the screen
    this->_labelShouldRetain->setPosition(Point(size.width/2, size.height/2));

    this->_arrowsBarShouldRetain->setVisible(false);

    float arrowsWidth = (ArrowsMax - ArrowsMin) * size.width;
    this->_arrowsBarShouldRetain->setScaleX(arrowsWidth / this->_arrowsBarShouldRetain->getContentSize().width);
    this->_arrowsBarShouldRetain->setPosition(Point(((ArrowsMax + ArrowsMin) / 2) * size.width, this->_labelShouldRetain->getPosition().y));

    this->snapArrowsToEdge();

    stringMenu->setPosition(Point(size.width/2, size.height - menuItemPaddingCenter));
    alignmentMenu->setPosition(Point(size.width/2, menuItemPaddingCenter+15));

    this->addChild(this->_labelShouldRetain);
    this->addChild(this->_arrowsBarShouldRetain);
    this->addChild(this->_arrowsShouldRetain);
    this->addChild(stringMenu);
    this->addChild(alignmentMenu);
}
开发者ID:fordream,项目名称:Snake,代码行数:68,代码来源:LabelTestNew.cpp

示例5: switch

bool GameMap::init()
{
	if(!Node::init())
		return false;

	//Ìí¼Óש¿é
	std::string block_file;
	std::string npc_file;

	switch(level)
	{
	case SPRING:
		block_file="block_spring.png";
		npc_file="lvshuiling.png";
		break;
	case WINTER:
		block_file="block_winter.png";
		npc_file="lanmogu.png";
		break;
	}

	std::string star_file="star.png";
	std::string tool_file="accelerate.png";

	//ÊÖ¶¯´î½¨µØͼ£¬Ã»ÓмÓÈ뼴ʱ¼ÆËã~
	//1²ã
	for(int i=0;i<10;i++)
	{
		if(i!=3&&i!=4&&i!=7&&i!=8)
		{
			//Ìí¼Óland
			auto block=Sprite::create(block_file);
			block->setPosition(BLOCK_SIZE/2+i*BLOCK_SIZE,BLOCK_SIZE/2+1*BLOCK_SIZE);
			this->addChild(block);
			block->setTag(LAND); //ÉèÖÃtag
			auto blockBody=PhysicsBody::createBox(block->getContentSize());
			blockBody->setDynamic(false);
			blockBody->setContactTestBitmask(1);
			blockBody->getShape(0)->setRestitution(0);
			block->setPhysicsBody(blockBody);
		}
	}
	//2²ã
	for(int i=0;i<10;i++)
	{
		if(i==2||i==5||i==6)
		{
			//Ìí¼Ó¹ÖÎï
			auto npc=Sprite::create(npc_file);
			npc->setTag(NPC);
			npc->setPosition(BLOCK_SIZE/2+i*BLOCK_SIZE,BLOCK_SIZE/2+2*BLOCK_SIZE);
			auto npcBody=PhysicsBody::createBox(npc->getContentSize());
			npcBody->setDynamic(false);
			npcBody->setContactTestBitmask(1);
			npcBody->getShape(0)->setRestitution(0);
			npc->setPhysicsBody(npcBody);
			this->addChild(npc);
		}
		if(i==3)
		{
			//Ìí¼Óland
			auto block=Sprite::create(block_file);
			block->setPosition(BLOCK_SIZE/2+i*BLOCK_SIZE,BLOCK_SIZE/2+1*BLOCK_SIZE);
			this->addChild(block);
			block->setTag(LAND); //ÉèÖÃtag
			auto blockBody=PhysicsBody::createBox(block->getContentSize());
			blockBody->setDynamic(false);
			blockBody->setContactTestBitmask(1);
			blockBody->getShape(0)->setRestitution(0);
			block->setPhysicsBody(blockBody);
		}
	}
	//3²ã
	for(int i=0;i<10;i++)
	{
		if(i!=0&&i!=3&&i!=4)
		{
			//Ìí¼ÓÐÇÐÇ
			auto star1=Sprite::create(star_file);
			star1->setTag(STAR);
			star1->setPosition(PICKUP_SIZE/2+i*BLOCK_SIZE,BLOCK_SIZE/2+3*BLOCK_SIZE);
			auto starBody1=PhysicsBody::createBox(star1->getContentSize());
			starBody1->setDynamic(false);
			starBody1->setContactTestBitmask(1);
			starBody1->getShape(0)->setRestitution(0.0f);
			star1->setPhysicsBody(starBody1);
			this->addChild(star1);

			auto star2=Sprite::create(star_file);
			star2->setTag(STAR);
			star2->setPosition(PICKUP_SIZE/2*3+i*BLOCK_SIZE,BLOCK_SIZE/2+3*BLOCK_SIZE);
			auto starBody2=PhysicsBody::createBox(star2->getContentSize());
			starBody2->setDynamic(false);
			starBody2->setContactTestBitmask(1);
			starBody2->getShape(0)->setRestitution(0.0f);
			star2->setPhysicsBody(starBody2);
			this->addChild(star2);

		}

//.........这里部分代码省略.........
开发者ID:tashaxing,项目名称:MyParkourGame,代码行数:101,代码来源:GameMap.cpp

示例6: addChild


//.........这里部分代码省略.........
    myplane=Sprite::create("res/plpl.png");
    myplane->setPosition(300,300);
    auto body = PhysicsBody::createBox(Size(70, 40));
    body->setMass(1000);
    myplane->setPhysicsBody(body);
    addChild(myplane);
    
    auto dispatcher = Director::getInstance()->getEventDispatcher();
    auto myListener = EventListenerTouchOneByOne::create();
    
    //如果不加入此句消息依旧会向下传递
    myListener->setSwallowTouches(true);
    
    touchdown = false;

    float playfield_width = visibleSize.width * 2.0; // make the x-boundry 2 times the screen width
    float playfield_height = visibleSize.height * 2.0; // make the y-boundry 2 times the screen height
    Point center = Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y);
    //note : since bounddries are 2 times the screen size calculate new center point
    
    
//    this->runAction(Follow::create(myplane) );
    myplane->getPhysicsBody()->setVelocityLimit(200);
    
    fire = ParticleSun::create();
    fire->setTexture(Director::getInstance()->getTextureCache()->addImage("res/fire.png"));
    
//    fire->setGravity(Vec2(-300,0));
    addChild(fire);
    

    myplane->getPhysicsBody()->getPosition();
    
    myListener->onTouchBegan = [=](Touch* touch,Event* event)
    {
        //some check
        CCLOG("touchbegin");
        touchdown = true;

        if (1)
        {
            return true;
        }
        return false;  
    };
    
    for (int i = 0; i<0; i++) {
        auto x =  arc4random()%(int)width;
        auto y =  arc4random()%(int)height;
        Sprite* rock = Sprite::create("res/debris.png");
        rock->setPosition(x,y);
        rock->setScale(0.3);
        addChild(rock);
        
        rock->setPosition(x,y);
        
        auto rockbody = PhysicsBody::createCircle(30);
//        rockbody->setDynamic(false);
        auto vx =arc4random()%300;
        auto vy =arc4random()%300;
//        rockbody->setVelocity(Vec2(vx-150,vy-150));
        rockbody->setMass(1000);
        rock->setPhysicsBody(rockbody);
        
    }
    
    
    myListener->onTouchMoved = [=](Touch* touch,Event* event)
    {

    };
    
    myListener->onTouchEnded = [=](Touch* touch,Event* event)
    {
        touchdown = false;
        auto angle = myplane->getPhysicsBody()->getRotation();
        
        
        
        auto angle1 = (angle+0) /180*M_PI;
        auto angle2 = (angle+90) /180*M_PI;
//        myplane->getPhysicsBody()->applyForce(Vec2(-600000*cos(angle1),-600000*sin(angle1)));
//        myplane->getPhysicsBody()->applyForce(Vec2(-400000*cos(angle2),-400000*sin(angle2)));
        myplane->getPhysicsBody()->resetForces();
        
        
    };
    dispatcher->addEventListenerWithSceneGraphPriority(myListener,this);

    auto edgeSp = Sprite::create();
    auto body2 = PhysicsBody::createEdgeBox(Size(visibleSize.width*30,visibleSize.height));

    edgeSp->setPosition(Point(visibleSize.width/2,visibleSize.height/2));
    edgeSp->setPhysicsBody(body2);
    this->addChild(edgeSp);
    edgeSp->setTag(0);
    
    scheduleUpdate();
    return true;
}
开发者ID:xcstream,项目名称:flappy-retry,代码行数:101,代码来源:FPPlayScene.cpp

示例7: gameover

void Player::update(float dt) {
	//////////爆風に当たってたらゲームオーバーにする///////////
	if (scene->mapcontrol->getblock(getPosition())->firenull() == false) {
		gameover();
	}
	///////enterキーでボム設置///////////////
	if (obsevekey->getkey((Observekey::Key)playerkey.bomset) == 2
		&& bomcon->getChildrenCount()<maximumbom) {
		bomset();
	}
	//////主人公移動////////////////////////
	//主人公がmoveアニメーションしていないとき
	if (getActionByTag(1) == nullptr) {
		static int x = 0, y = 0;
		if (obsevekey->getkey((Observekey::Key)playerkey.right) != 0) {

			if (x == 16 && y == 0) {}
			else {
				setTexture("シロボン右.png");
				stopActionByTag(2);
				runAction(action[RIGHT]);
				x = 16; y = 0;
			}
		}
		else if (obsevekey->getkey((Observekey::Key)playerkey.left) != 0) {
			if (x == -16 && y == 0) {}
			else {
				setTexture("シロボン左.png");
				stopActionByTag(2);
				runAction(action[LEFT]);
				x = -16; y = 0;
			}
		}
		else if (obsevekey->getkey((Observekey::Key)playerkey.up) != 0) {
			if (x == 0 && y == 16) {}
			else {
				setTexture("シロボン前.png");
				stopActionByTag(2);
				runAction(action[FRONT]);
				x = 0; y = 16;
			}
		}
		else if (obsevekey->getkey((Observekey::Key)playerkey.down) != 0) {
			if (x == 0 && y == -16) {}
			else {
				setTexture("シロボン後.png");
				stopActionByTag(2);
				runAction(action[BACK]);
				x = 0; y = -16;
			}
		}
		else { stopActionByTag(2); x = 0; y = 0; return; }
		//移動先に障害物がないとき
		if (scene->mapcontrol->getblock(Vec2(getPositionX() + x,getPositionY() + y))->obstaclecheck() == false) {
			//1ブロック分移動
			auto move = MoveBy::create(speed, Vec2(x, y));
			move->setTag(1);
			runAction(move);
		}

	}
}
开发者ID:elipmoc,项目名称:cocos2dx,代码行数:62,代码来源:Player.cpp

示例8: addChild

	// on "init" you need to initialize your instance
	bool ChooserScene::init(int _offset)
	{
		offset = _offset;
		//////////////////////////////
		// 1. super init first
		if (!Layer::init())
		{
			return false;
		}

		Size visibleSize = Director::getInstance()->getVisibleSize();

		string title = vector < string > {
			"Moon",
				"Mars",
				"Uranus"
		}[GameSettings::CurrentEpisode];

		auto hooker = TopAnchor::create();
		addChild(hooker, 1);

		auto episodetitle = Label::createWithTTF(title, FANCY_TTF, 60.0f);
		episodetitle->setHorizontalAlignment(TextHAlignment::CENTER);
		episodetitle->setPosition(VCP(0.5f, 0.9f));
		hooker->addChild(episodetitle);

		auto pMenu = Menu::create();
		pMenu->setPosition(Point::ZERO);
		hooker->addChild(pMenu, 1);

		auto btnMenu = MAKEBUTTON("btnMenuUp", "btnMenuDn", ChooserScene::btnMenuPressed);
		btnMenu->setPosition(VCP(0, 1));
		btnMenu->setAnchorPoint(Point(-0.5, 1.5));
		btnMenu->setScale(1.3f);
		pMenu->addChild(btnMenu);

		auto pLevels = Menu::create();
		pLevels->setPosition(Point::ZERO);
		pLevels->setTag(0);
		hooker->addChild(pLevels);

		const float startX = 0.2f;
		const float startY = 0.25f;

		auto bSprite = Sprite::createWithSpriteFrameName("circle");
		auto contentsize = bSprite->getContentSize();
		float off = 1.0f - (2.0f * startX);
		off /= (float) (lCount - 1);
		float offy = 1.0f - (startY * 2.0f);
		offy /= (float) (rCount - 1);
		log("Unlocked Level ID:" + nToString(GameSettings::GetUnlockedLevelId()));
		float y = startY;

		GLubyte cR = 255;
		for (int r = 0; r < rCount; r++)
		{
			float x = startX;
			GLubyte cG = 200; // static_cast<GLubyte>(200.0f * (float) offset / (float) GameSettings::MaximumLevelId);
			GLubyte cB = 20; // +200 - static_cast<GLubyte>(200.0f * (float) offset / (float) GameSettings::MaximumLevelId);;
			for (int i = 0; i < lCount; i++)
			{
				int levelId = offset + (rCount - (r + 1)) * lCount + i;
				if (levelId >= GameSettings::GetMaximumLevelId()) break;

				Node* btn;
				if (levelId <= GameSettings::GetUnlockedLevelId())
				{
					btn = MAKEBUTTON("circle", "circleDn", ChooserScene::btnLevelPressed);
					btn->setTag(100 + levelId);
					pLevels->addChild(btn);
					blobs.push_back(btn);
					btn->setPosition(VCP(x, y));

					Label* lbl = Label::createWithSystemFont(nToString(levelId + 1).c_str(), "Consolas", 28.0);
					lbl->setColor(Color3B::WHITE);
					lbl->setPosition(VCP(x, y));
					numbers.push_back(lbl);
					this->addChild(lbl, 1);

					btn->setColor(Color3B(cR, cG, cB));
				}
				else
				{
					btn = Sprite::createWithSpriteFrameName("circleLk");
					btn->setTag(100 + levelId);
					hooker->addChild(btn);
					blobs.push_back(btn);
					btn->setPosition(VCP(x, y));
				}
				btn->setScale(0.8f);
#if ENABLE_IAD
				//btn->setScale(0.8f);
#endif
				cG *= 0.5;
				cB *= 1.7;
				cB = cB > 255 ? 255 : cB;

				x += off;
			}
//.........这里部分代码省略.........
开发者ID:OscarLeif,项目名称:CocosNeat,代码行数:101,代码来源:PlatformerChooserScene.cpp

示例9: addParticalToHead

Head_ParticalEffect

void addParticalToHead(Node* node)
{
	Vec2 pos[4];
	pos[0] = Vec2(5, 75);
	pos[1] = Vec2(75, 75);
	pos[2] = Vec2(75, 5);
	pos[3] = Vec2(5, 5);

	for (int i = 0; i < 2; i++)
	{
		auto   partNode = ParticleSystemQuad::createWithTotalParticles(60);
		partNode->setTexture(TextureCache::getInstance()->addImage("GameUI/CommonUI/fire.png"));//设置粒子图
		partNode->setDuration(-1);//发射时长

		// life of particles
		partNode->setLife(0.5f);//粒子生命
		partNode->setLifeVar(0.1f);

		partNode->setEmissionRate(partNode->getTotalParticles() / partNode->getLife());//发射器发射频率
		partNode->setPositionType(ParticleSystem::PositionType::FREE);//设置发射器的跟随模式

		// color of particles
		partNode->setStartColor(ccc4f(0.76f, 0.25f, 0.12f, 1.0f));//起始颜色
		partNode->setStartColorVar(ccc4f(0.1f, 0.1f, 0.1f, 0.0f));

		partNode->setEndColor(ccc4f(1.0f, 1.0f, 1.0f, 1.0f));//结束颜色
		partNode->setEndColorVar(ccc4f(0.1f, 0.1f, 0.1f, 0.1f));

		// size, in pixels
		partNode->setStartSize(15);//粒子大小
		partNode->setStartSizeVar(3);
		partNode->setEndSize(0);
		partNode->setEndSizeVar(3);

		// angle
		partNode->setAngle(0);//发射器角度
		partNode->setAngleVar(0);

		// speed of particles
		partNode->setSpeed(0);//粒子速度
		partNode->setSpeedVar(0);

		// emitter position
		partNode->setPosVar(ccp(0, 0));//发射器位置变化

		partNode->setBlendAdditive(true);

		node->addChild(partNode);
		partNode->setTag(PARTICALTAG);
		auto move0 = MoveTo::create(1.f, pos[0]);
		auto move1 = MoveTo::create(1.f, pos[1]);
		auto move2 = MoveTo::create(1.f, pos[2]);
		auto move3 = MoveTo::create(1.f, pos[3]);

		if (i == 0)
		{
			partNode->setPosition(pos[0]);
			partNode->runAction(RepeatForever::create(Sequence::create(move1, move2, move3, move0, nullptr)));
		}
		else
		{
			partNode->setPosition(pos[2]);
			partNode->runAction(RepeatForever::create(Sequence::create(move3, move0, move1, move2, nullptr)));
		}

	}
}
开发者ID:YuYing-yy,项目名称:Tools-Code,代码行数:69,代码来源:Head_ParticalEffect.cpp

示例10: init

bool ActionScene::init()
{
	if (! Scene::init())
	{
		return false;
	}

	//
	auto bkqSpr = Sprite::create("bkq1.png");
	bkqSpr->setPosition(DISPLAY_CX, DISPLAY_CY);
	bkqSpr->setTag(111);
	bkqSpr->setName("bkq");
	addChild(bkqSpr);

	frmTime = 0; 
	//scheduleUpdate();

	//to by
	//auto action = MoveBy::create(2.0f, Vec2(200, 0));
	//auto action = MoveTo::create(2.0f, Vec2(200, 0));
	
	//auto action = JumpTo::create(2.0f, Vec2(DISPLAY_CX + 200, DISPLAY_CY), 100, 5);
	//auto action = JumpBy::create(0.5f, Vec2(200, 0), 200, 1);

	//±´Èû¶ûÇúÏß
	/*
	ccBezierConfig bezierCfg;
	bezierCfg.endPosition = Point(DISPLAY_CX + 400, DISPLAY_CY);
	bezierCfg.controlPoint_1 = Point(DISPLAY_CX , DISPLAY_CY +200);
	bezierCfg.controlPoint_2 = Point(DISPLAY_CX + 500, DISPLAY_CY - 200);
	auto action = CCBezierTo::create(2.0f,bezierCfg);
	*/

	//auto actionScale = ScaleTo::create(2.0f,0.5);
	//auto actionRotate = RotateBy::create(2.0f, 180);

	//auto action = Sequence::create(actionScale,actionRotate,NULL);
	//auto action = Spawn::create(actionScale, actionRotate, NULL);

	/**/
	/*
	auto moveActionRight = MoveBy::create(1.0f, Vec2(200, 0));
	auto moveActionLeft = moveActionRight->reverse();//MoveBy::create(1.0f, Vec2(-200, 0));

	auto flipAction = FlipX::create(true);
	auto flipAction1 = FlipX::create(false);
	auto delayAction = DelayTime::create(1.0f);

	auto seqAction = Sequence::create(moveActionRight, delayAction,flipAction
		, moveActionLeft, delayAction, flipAction1, NULL);

	//auto action = Repeat::create(seqAction, 20);
	auto action = RepeatForever::create(seqAction);
	*/


	//FADE
	//auto action = FadeOut::create(5.f);
	//tint
	//auto action = TintBy::create(3.f, 100, -30, 50);
	//blink
	//auto action = Blink::create(3.f, 10);

	//func
	auto moveAction = MoveBy::create(2.f, Vec2(200, 0));

	//auto action = Sequence::create(moveAction,
	//	CallFunc::create(CC_CALLBACK_0(ActionScene::endFunction,this))
	//	, NULL);
	auto action = Sequence::create(moveAction,
		CallFunc::create(std::bind(&ActionScene::endFunction,this)), NULL);
	bkqSpr->runAction(action);

	return true;
}
开发者ID:caiwb1990,项目名称:cocosClass,代码行数:75,代码来源:ActionScene.cpp

示例11: if

bool Help::init() {
	if (!Layer::init()) {
		return false;
	}

	Size visibleSize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();


	//背景精灵
	if (getPass() == 1) {
		auto bg1 = Sprite::create("help_bg1.jpg");
		//为适应屏幕进行缩放
		bg1->setScaleX((float)visibleSize.width / (float)bg1->getContentSize().width);
		bg1->setScaleY((float)visibleSize.height / (float)bg1->getContentSize().height);
		bg1->setPosition(Vec2(origin.x + visibleSize.width / 2, 0));
		bg1->setAnchorPoint(Vec2(0.5, 0));
		bg1->setTag(101);
		this->addChild(bg1, 0);
	}
	else if (getPass() == 2) {
		auto bg1 = Sprite::create("help_bg2.jpg");
		//为适应屏幕进行缩放
		bg1->setScaleX((float)visibleSize.width / (float)bg1->getContentSize().width);
		bg1->setScaleY((float)visibleSize.height / (float)bg1->getContentSize().height);
		bg1->setPosition(Vec2(origin.x + visibleSize.width / 2, 0));
		bg1->setAnchorPoint(Vec2(0.5, 0));
		bg1->setTag(101);
		this->addChild(bg1, 0);
	}
	else if (getPass() == 3){
		auto bg1 = Sprite::create("help_bg3.jpg");
		//为适应屏幕进行缩放
		bg1->setScaleX((float)visibleSize.width / (float)bg1->getContentSize().width);
		bg1->setScaleY((float)visibleSize.height / (float)bg1->getContentSize().height);
		bg1->setPosition(Vec2(origin.x + visibleSize.width / 2, 0));
		bg1->setAnchorPoint(Vec2(0.5, 0));
		bg1->setTag(101);
		this->addChild(bg1, 0);
	}
	else if (getPass() == 4) {
		auto bg1 = Sprite::create("help_bg4.png");
		//为适应屏幕进行缩放
		bg1->setScaleX((float)visibleSize.width / (float)bg1->getContentSize().width);
		bg1->setScaleY((float)visibleSize.height / (float)bg1->getContentSize().height);
		bg1->setPosition(Vec2(origin.x + visibleSize.width / 2, 0));
		bg1->setAnchorPoint(Vec2(0.5, 0));
		bg1->setTag(101);
		this->addChild(bg1, 0);
	}
	else if (getPass() == 5) {
		auto bg1 = Sprite::create("help_bg4.png");
		//为适应屏幕进行缩放
		bg1->setScaleX((float)visibleSize.width / (float)bg1->getContentSize().width);
		bg1->setScaleY((float)visibleSize.height / (float)bg1->getContentSize().height);
		bg1->setPosition(Vec2(origin.x + visibleSize.width / 2, 0));
		bg1->setAnchorPoint(Vec2(0.5, 0));
		bg1->setTag(101);
		this->addChild(bg1, 0);
	}
	
	auto MagicItem = MenuItemImage::create("continue.png", "continue2.png",
		CC_CALLBACK_1(Help::menuContinueCallback, this));
	MagicItem->setPosition(Vec2(visibleSize.width - MagicItem->getContentSize().width - 20, MagicItem->getContentSize().height * 2));
	MagicItem->setAnchorPoint(Vec2(0.5, 0.5));
	auto menu = Menu::create(MagicItem, NULL);
	menu->setPosition(Vec2::ZERO);
	this->addChild(menu, 1);

	return true;
}
开发者ID:xurui25,项目名称:cocos2d-x-,代码行数:71,代码来源:help.cpp

示例12: init

bool StartGame:: init(){
    if (!Layer::init()) {
        return false;
    }
     itemArray=__Array::create();
     itemArray->retain();
     int k=arc4random()%6+1;
     std::string str= StringUtils::format("mineBG%d.png",k);
     auto visibleSize=Director::getInstance()->getVisibleSize();
     auto sprite=Sprite::create(str);
     sprite->setPosition(visibleSize.width/2,visibleSize.height/2);
     this->addChild(sprite);
    //离子
    ParticleSystemQuad* quad = ParticleSystemQuad::create("fengye.plist");
    quad->setBlendAdditive(true);
    quad->setAutoRemoveOnFinish(true);
    quad->setPosition(Vec2(400, 300));
    this->addChild(quad);

    //黄金
     char a[50];
     sprintf(a, "%d",score[level-1]);
     auto sprite1=Sprite::create("Gold.png");
     sprite1->setPosition(visibleSize.width/2-200,visibleSize.height/2+130);
     auto lable1=Label::createWithSystemFont(a, "fonts/Marker Felt.ttf ", 28);
     lable1->setTextColor(Color4B::GREEN);
     lable1->setPosition(visibleSize.width/2-150,visibleSize.height/2+130);
     lable1->setTag(10);
     this->addChild(lable1);
     this->addChild(sprite1);
    
    //钱
     auto sprite2=Sprite::create("rmbImage.png");
     sprite2->setPosition(visibleSize.width/2-200,visibleSize.height/2+90);
     auto lable2=Label::createWithSystemFont("0", "fonts/Marker Felt.ttf ", 28);
     lable2->setPosition(visibleSize.width/2-150,visibleSize.height/2+90);
     lable2->setTag(20);
     lable2->setTextColor(Color4B::RED);
     this->addChild(lable2);
     this->addChild(sprite2);
    
    //矿工
     auto sprite3=Sprite::create("miner_0707.png");
     sprite3->setPosition(visibleSize.width/2+180,visibleSize.height/2+130);
     char c[50];
     sprintf(c, "%d",level);
     auto lable3=Label::createWithSystemFont(c, "fonts/Marker Felt.ttf ", 28);
     lable3->setPosition(visibleSize.width/2+220,visibleSize.height/2+130);
     lable3->setTag(30);
     lable3->setTextColor(Color4B::GREEN);
     this->addChild(lable3);
     this->addChild(sprite3);
    
    
     char d[50];
     sprintf(d, "%d",totalTime[level-1]);
     auto sprite4=Sprite::create("clockPlate.png");
     sprite4->setTag(4);
     sprite4->setPosition(visibleSize.width/2+180,visibleSize.height/2+90);
     auto lable4=Label::createWithSystemFont(d, "fonts/Marker Felt.ttf ", 28);
     lable4->setPosition(visibleSize.width/2+220,visibleSize.height/2+90);
     lable4->setTag(40);
     lable4->setTextColor(Color4B::GREEN);
     this->addChild(lable4);
     this->addChild(sprite4);
    
    
    auto item=MenuItemImage::create("qianglishui.png", "qianglishui.png");
    auto item1=MenuItemImage::create("qianglishui.png", "qianglishui.png");
    toggle=MenuItemToggle::create();
    toggle->addSubItem(item);
    toggle->addSubItem(item1);
    toggle->setScale(0.5);
    toggle->setSelectedIndex(0);
    toggle->setCallback([this](Ref*){
        //减少PowerWater数量
        auto lable=(Label*)this->getChildByTag(50);
        int num= atoi(lable->getString().c_str());
        if (num!=0){
            Water--;
            miner->setScale(1.5);
            
            //this->schedule(schedule_selector(StartGame::changeSelect),8);
             this->schedule(CC_CALLBACK_1(StartGame::changeSelect,this), 8, "changeSelect");
            
            lable->setString(StringUtils::format("%d",Water));
            this->testCollin(1.0);
        }else  if(num==0){
            toggle->setSelectedIndex(0);
            log("%d",toggle->getSelectedIndex());
        }
    });
    menu=Menu::create(toggle, NULL);
    menu->setPosition(Vec2(visibleSize.width/2+180, visibleSize.height/2+50));
    std::string str1=  StringUtils::format("%d",Water);
    lable5=Label::createWithSystemFont(str1,"fonts/Marker Felt.ttf", 28);
    lable5->setPosition(Vec2(visibleSize.width/2+220, visibleSize.height/2+50));
    lable5->setTag(50);
    lable5->setTextColor(Color4B::GREEN);
    this->addChild(lable5);
//.........这里部分代码省略.........
开发者ID:baokuanze,项目名称:GoildMiner,代码行数:101,代码来源:StartGame.cpp

示例13: addChild

bool LevelTwentytwo::init()
{
	if (!Layer::init())
	{
		return false;
	}

	// 用于解决刚体穿透问题
	this->scheduleUpdate();
	// 计时器
	this->schedule(schedule_selector(LevelTwentytwo::timeCounter), 1.0f);

	auto visibleSize = Director::getInstance()->getVisibleSize();
	auto origin = Director::getInstance()->getVisibleOrigin();

	// 加载背景贴图
	auto spriteBg = Sprite::create("background.png");
	spriteBg->setAnchorPoint(Vec2::ZERO);
	spriteBg->setPosition(Vec2::ZERO);
	addChild(spriteBg);

	ballOne = Sprite::createWithSpriteFrameName("hero.png");
	ballOne->setPosition(visibleSize.width / 2.0f, ballOne->getContentSize().height);

	auto ballBodyOne = PhysicsBody::createCircle(ballOne->getContentSize().width / 2, PHYSICSBODY_MATERIAL_DEFAULT);
	//是否设置物理为静态
	//ballBodyOne->setDynamic(false);
	//设置物理的恢复力
	ballBodyOne->getShape(0)->setRestitution(0.5f);
	//设置物体的摩擦力
	ballBodyOne->getShape(0)->setFriction(0.0f);
	ballBodyOne->getShape(0)->setDensity(0.3f);
	// 设置质量 质量等于密度乘以面积
	//ballBodyOne->getShape(0)->setMass(5000);
	// 设置物体是否受重力系数影响
	ballBodyOne->setGravityEnable(true);
	ballBodyOne->setCategoryBitmask(1);// 分类掩码
	ballBodyOne->setCollisionBitmask(1 | 2 | 4 | 8);// 碰撞掩码
	ballBodyOne->setContactTestBitmask(8);// 接触测试掩码

	// 把物体添加到精灵
	ballOne->setPhysicsBody(ballBodyOne);
	this->addChild(ballOne);

	auto girl = Sprite::createWithSpriteFrameName("girl.png");
	girl->setPosition(visibleSize.width / 2.0f, visibleSize.height / 2.0f + 250.0f);
	auto girlBody = PhysicsBody::createCircle(girl->getContentSize().width / 2.0f, PHYSICSBODY_MATERIAL_DEFAULT);
	girlBody->setDynamic(false);
	girlBody->setGravityEnable(false);
	girlBody->setCategoryBitmask(8);
	girlBody->setCollisionBitmask(1);
	girlBody->setContactTestBitmask(1);
	girl->setPhysicsBody(girlBody);
	this->addChild(girl);

	//创建一个盒子,用来碰撞
	auto edgeSpace = Sprite::create();
	auto boundBody = PhysicsBody::createEdgeBox(visibleSize, PHYSICSBODY_MATERIAL_DEFAULT, 3);
	boundBody->getShape(0)->setFriction(0.0f);
	boundBody->getShape(0)->setRestitution(1.0f);

	edgeSpace->setPhysicsBody(boundBody);
	edgeSpace->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2));
	this->addChild(edgeSpace);
	edgeSpace->setTag(0);

	boundBody->setCategoryBitmask(4);
	boundBody->setCollisionBitmask(1 | 2 | 4);
	boundBody->setContactTestBitmask(0);

	// 随机位置
	int index = CCRANDOM_0_1() * 4;
	auto suiji1 = 0;
	auto suiji2 = 0;
	auto suiji3 = 0;
	switch (index)
	{
	case 0:
		suiji1 = CCRANDOM_0_1() * 240;
		suiji2 = -CCRANDOM_0_1() * 100;
		suiji3 = -CCRANDOM_0_1() * 150;
		break;
	case 1:
		suiji1 = -CCRANDOM_0_1() * 240;
		suiji2 = -CCRANDOM_0_1() * 100;
		suiji3 = -CCRANDOM_0_1() * 150;
		break;
	case 2:
		suiji1 = -CCRANDOM_0_1() * 240;
		suiji2 = CCRANDOM_0_1() * 100;
		suiji3 = CCRANDOM_0_1() * 150;
		break;
	case 3:
		suiji1 = CCRANDOM_0_1() * 240;
		suiji2 = CCRANDOM_0_1() * 100;
		suiji3 = CCRANDOM_0_1() * 150;
		break;
	default:
		break;
	}
//.........这里部分代码省略.........
开发者ID:xianglin-love,项目名称:threeColor,代码行数:101,代码来源:LevelTwentytwo.cpp

示例14: dataRow

void MakeItemUI::UpdateUI()
{
    auto layout_Template = m_RootWidget->getChildByName<Layout*>("Layout_Template");
    
    //有新建筑可建或有建筑可建
    auto layout_Item_Template = layout_Template->getChildByName<Layout*>("Layout_Item");
    
    auto layout_Center = m_RootWidget->getChildByName<Layout*>("Layout_Center");
    
    auto lView_List = layout_Center->getChildByName<ListView*>("LView_List");
    
    vector<pair<int, Value>> viv;
    //每次清空 子控件
    lView_List->removeAllChildren();

    vector<pair<int, Value>> viv_MakeItem;
    ValueMap* vm_MakeItem =  &(UserData::getInstance()->GetUserData(UserDataEnum::MakeItem)->asValueMap());
    UserData::getInstance()->VMSKToVIV_Sort(vm_MakeItem, &viv_MakeItem);
    
    for (auto iter = viv_MakeItem.begin(); iter != viv_MakeItem.end(); iter++)
    {
        auto cfgId = iter->first;
        if(UserData::getInstance()->Check_VI_Fun(UserDataEnum::OnlyItemList, Value(cfgId)))
        {
            continue;
        }
        
        auto layout_Item = layout_Item_Template->clone();
        layout_Item->setVisible(true);
        lView_List->addChild(layout_Item);
        CfgDataRow dataRow(cfgId);
        
        auto langId = dataRow.GetValue(CfgField::Name)->asInt();
        auto langText = MultiLanguage::getInstance()->GetText(langId);
        
        auto btn_Name = layout_Item->getChildByName<Button*>("Btn_Name");
        btn_Name->setTitleText(langText.c_str());
        btn_Name->getChildByName<ImageView*>("Sprite_New")->setVisible(iter->second.asBool());
        UIUtils::getInstance()->addMakeBatches(btn_Name, this, cfgId);
        btn_Name->addClickEventListener([this, cfgId, btn_Name](Ref* sender)
        {
            if (btn_Name->getTag() == BTN_IS_LONGBTN) {
                btn_Name->setTag(BTN_NOT_LONGBTN);
                return;
            }
            
            CfgDataRow dataRow(cfgId);
            auto vmi_Price = dataRow.GetValue(CfgField::MaterialID_M)->asIntMultiKeyMap();
            
            vector<pair<int, int> > lackData;
            bool delResutl = UserData::getInstance()->DeleteStorehouseData(&vmi_Price, &lackData);
            if (delResutl)
            {
                makeItemEvent(cfgId);
                MsgListNode::getInstance()->NewMsg(cfgId, 1, CfgField::Schedule);
                UpdateUI();
            }else
            {
                int totalNum = UIUtils::getInstance()->getLackCostDiamond(&lackData);
                string showText = StringUtils::format(MultiLanguage::getInstance()->GetText((int)LanguageIdEnum::Diamond_ToGet).c_str(), totalNum) + MultiLanguage::getInstance()->GetText(dataRow.GetValue(CfgField::Name)->asInt());
                UIUtils::getInstance()->addLeadBuyLayer(this, showText, totalNum,
                                                        [=]()
                                                        {
                                                            UIUtils::getInstance()->costUpgNeededItem(&vmi_Price, &lackData);
                                                            makeItemEvent(cfgId);
                                                            MsgListNode::getInstance()->NewMsg(cfgId, 1, CfgField::Schedule);
                                                            UpdateUI();
                                                        });
                
                MoveText::getInstance()->LackResText(m_RootWidget, &lackData);
            }
            
        });
        
        auto level = dataRow.GetValue(CfgField::Level)->asInt();
        auto layout_Start = layout_Item->getChildByName<Layout*>("Start");
        if (layout_Start != nullptr)
        {
            for (auto i = 1; i <= level; i++)
            {
                auto startName = StringUtils::format("Start_%d", i - 1);
                auto imgStart = layout_Start->getChildByName<ImageView*>(startName);
                if (imgStart != nullptr) imgStart->setVisible(true);
            }
        }

        viv.clear();
        auto vmim = dataRow.GetValue(CfgField::MaterialID_M)->asIntMultiKeyMap();
        CfgData::getInstance()->VMIMKToVIV_Sort(&vmim, &viv);
        for (auto i = 0; i < (viv.size() > 3 ? 3 : viv.size()); i++)
        {
            auto textName = StringUtils::format("Text_NameNum%d",i);
            auto text_NameNum = layout_Item->getChildByName<Text*>(textName);
            langId = CfgData::getInstance()->GetValue(viv[i].first, CfgField::Name)->asInt();
            langText = MultiLanguage::getInstance()->GetText(langId);
            
            text_NameNum->setString(StringUtils::format("%s x%d", langText.c_str(), viv[i].second.asInt()));
            if(!UIUtils::getInstance()->isStuffEnough(viv[i].first, viv[i].second.asInt()))
            {
                // 数量不足,置灰
//.........这里部分代码省略.........
开发者ID:cxfshelter,项目名称:TokenGame,代码行数:101,代码来源:MakeItemUI.cpp

示例15: CC_PROFILER_START

void ArrayPerfTest::generateTestFunctions()
{
    auto createArray = [this](){
        __Array* ret = Array::create();
        
        for( int i=0; i<quantityOfNodes; ++i)
        {
            auto node = Node::create();
            node->setTag(i);
            ret->addObject(node);
        }
        return ret;
    };
    
    TestFunction testFunctions[] = {
        { "addObject",    [=](){
            __Array* nodeVector = Array::create();
            
            CC_PROFILER_START(this->profilerName());
            for( int i=0; i<quantityOfNodes; ++i)
                nodeVector->addObject(Node::create());
            CC_PROFILER_STOP(this->profilerName());
        } } ,
        { "insertObject",      [=](){
            __Array* nodeVector = Array::create();
            
            CC_PROFILER_START(this->profilerName());
            for( int i=0; i<quantityOfNodes; ++i)
                nodeVector->insertObject(Node::create(), 0);
            CC_PROFILER_STOP(this->profilerName());
        } } ,
        { "setObject",     [=](){
            __Array* nodeVector = createArray();
            
            srand((unsigned)time(nullptr));
            ssize_t index = rand() % quantityOfNodes;
            
            CC_PROFILER_START(this->profilerName());
            for( int i=0; i<quantityOfNodes; ++i)
                nodeVector->setObject(Node::create(), index);
            CC_PROFILER_STOP(this->profilerName());
        } } ,
        { "getIndexOfObject",    [=](){
            __Array* nodeVector = createArray();
            Ref* objToGet = nodeVector->getObjectAtIndex(quantityOfNodes/3);
            ssize_t index = 0;
            CC_PROFILER_START(this->profilerName());
            for( int i=0; i<quantityOfNodes; ++i)
                index = nodeVector->getIndexOfObject(objToGet);
            CC_PROFILER_STOP(this->profilerName());
            // Uses `index` to avoids `getIndex` invoking was optimized in release mode
            if (index == quantityOfNodes/3)
            {
                nodeVector->removeAllObjects();
            }
        } } ,
        { "getObjectAtIndex",          [=](){
            __Array* nodeVector = createArray();
            
            CC_PROFILER_START(this->profilerName());
            for( int i=0; i<quantityOfNodes; ++i)
                nodeVector->getObjectAtIndex(quantityOfNodes/3);
            CC_PROFILER_STOP(this->profilerName());
        } } ,
        { "containsObject",    [=](){
            __Array* nodeVector = createArray();
            Ref* objToGet = nodeVector->getObjectAtIndex(quantityOfNodes/3);
            
            CC_PROFILER_START(this->profilerName());
            for( int i=0; i<quantityOfNodes; ++i)
                nodeVector->containsObject(objToGet);
            CC_PROFILER_STOP(this->profilerName());
        } } ,
        { "removeObject", [=](){
            __Array* nodeVector = createArray();
            Node** nodes = (Node**)malloc(sizeof(Node*) * quantityOfNodes);
            
            for (int i = 0; i < quantityOfNodes; ++i)
            {
                nodes[i] = static_cast<Node*>(nodeVector->getObjectAtIndex(i));
            }
            
            CC_PROFILER_START(this->profilerName());
            for( int i=0; i<quantityOfNodes; ++i)
                nodeVector->removeObject(nodes[i]);
            CC_PROFILER_STOP(this->profilerName());
            
            CCASSERT(nodeVector->count() == 0, "nodeVector was not empty.");
            
            free(nodes);
        } } ,
        { "removeObjectAtIndex",       [=](){
            __Array* nodeVector = createArray();
            
            CC_PROFILER_START(this->profilerName());
            for( int i=0; i<quantityOfNodes; ++i)
                nodeVector->removeObjectAtIndex(0);
            CC_PROFILER_STOP(this->profilerName());
            
            CCASSERT(nodeVector->count() == 0, "nodeVector was not empty.");
//.........这里部分代码省略.........
开发者ID:AppleJDay,项目名称:cocos2d-x,代码行数:101,代码来源:PerformanceContainerTest.cpp


注:本文中的setTag函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。