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


C++ CCSprite::boundingBox方法代码示例

本文整理汇总了C++中CCSprite::boundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ CCSprite::boundingBox方法的具体用法?C++ CCSprite::boundingBox怎么用?C++ CCSprite::boundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCSprite的用法示例。


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

示例1: addMapBtnWith

CCSprite* LevelScene::addMapBtnWith(int no, cocos2d::CCPoint pos, CCSpriteBatchNode* batch)
{
    CCSprite *map = NULL;
    CCSprite *lockSprite = NULL;
    CCLabelAtlas *mapNo = CCLabelAtlas::create("0123456789", "fonts_score_002-hd.png", 38, 44, '0');

    if (FruitCrush::shareSingleton()->canPlayMap(no)) {
        map = CCSprite::createWithTexture(batch->getTexture());
        map->setTag(no);
        //map->setScale(0.6);
        CCString* num = CCString::createWithFormat("%u", no);
        mapNo->setString(num->getCString());
        //mapNo->setColor(ccc3(242, 247, 240));
        mapNo->setAnchorPoint(ccp(0.5f,0.5f));
        mapNo->setPosition(ccp(map->boundingBox().size.width/2, map->boundingBox().size.height/2));
        map->addChild(mapNo);
        //this->addChild(mapNo);
    }
    else
    {
        
    }
    
    map->setPosition(pos);
    map->setScale(0.8);
    this->addChild(map);
    return map;
    
}
开发者ID:lioneltsai,项目名称:fruitCrush,代码行数:29,代码来源:LevelScene.cpp

示例2:

CCSprite* Objects2dFactory::image(CCNode* scene, string imagePath, float positionX, float positionY, float width, float height, AlignX alignX, 
	AlignY alignY, int zOrder, void* argument)
{
	// Check arguments validity
	if(scene == NULL)
		return NULL;

	// Create an image
	CCSprite* image = CCSprite::create(imagePath.c_str());
    if(!image)
		return NULL;

    // Place the image in the given position
    image->setPosition(ccp(positionX, positionY));
	
	// Set anchor
	image->setAnchorPoint(ccp(Constants::getAnchorValue(alignX), Constants::getAnchorValue(alignY)));
	
	// Set size
	float imageWidth = image->boundingBox().size.width;
    image->setScaleX(width / imageWidth);
	float imageHeight = image->boundingBox().size.height;
    image->setScaleY(height / imageHeight);

	// Set argument as user data
	if (argument != NULL)
		image->setUserData(argument);

	// Add menu to the scene
	scene->addChild(image, zOrder);

	return image;
}
开发者ID:Cnotinfor,项目名称:TopQX_2D,代码行数:33,代码来源:Objects2dFactory.cpp

示例3: init

bool OptionLayer::init() {
    if (!CCLayer::init()) {
        return false;
    }

    _back = CCSprite::create("back.png");
    _back->setPosition(ccp(24 + 40, 800 - 56.5 + 15));
    this->addChild(_back);

    CCSprite * mode = CCSprite::create("mode.png");
    mode->setPosition(ccp(132 + 111, 800 - 103 - 19.5));
    this->addChild(mode);

    CCSpriteBatchNode* batchNode = CCSpriteBatchNode::create("dotted_line.png");
    int dottedLineY[3] = {313, 420, 539};
    for (int i = 0; i < 3; i++) {
        CCSprite * dotLine = CCSprite::createWithTexture(batchNode->getTexture());
        dotLine->setPosition(ccp(27 + 210.5, 800 - dottedLineY[i] - 1.5));
        this->addChild(dotLine);
    }

    _switchIndex = -1;
    _switches[0] = &Settings::showConflictedDigit;
    _switches[1] = &Settings::musicEnabled;
    _switches[2] = &Settings::soundEnabled;
    _switches[3] = &Settings::preventSleeping;
    _switches[4] = &Settings::showTimer;
    _switches[5] = &Settings::autoHighLight;
    _switches[6] = &Settings::autoRemoveNotes;
    _switches[7] = &Settings::removeCompleteDigits;

    CCSpriteBatchNode* maskBatchNode = CCSpriteBatchNode::create("mask.png");
    CCSpriteBatchNode* switchBatch = CCSpriteBatchNode::create("switch.png");
    _switchButtons = CCArray::createWithCapacity(7);
    _switchButtons->retain();
    char opLabel[10];
    int opLabelY[8] = {271, 332, 379, 445, 492, 566, 612, 657};
    for(int i = 0; i < 8; i++) {
        sprintf(opLabel, "op%d.png", i);
        CCSprite * label = CCSprite::create(opLabel);
        label->setPosition(ccp(25 + label->boundingBox().size.width / 2,
                               800 - opLabelY[i] - label->boundingBox().size.height / 2));
        this->addChild(label);

        CCSprite * stencil = CCSprite::createWithTexture(maskBatchNode->getTexture());
        stencil->setPosition(ccp(380 + 39, 800 - opLabelY[i] - label->boundingBox().size.height / 2));
        CCClippingNode * cliper = CCClippingNode::create(stencil);
        cliper->setAlphaThreshold(0);
        CCSprite * switchButton = CCSprite::createWithTexture(switchBatch->getTexture());
        switchButton->setPosition(ccp(*(_switches[i]) ? 394 + 49 : 394, 800 - opLabelY[i] - label->boundingBox().size.height / 2));
        _switchButtons->addObject(switchButton);
        cliper->addChild(switchButton);
        this->addChild(cliper);
    }

    this->setTouchEnabled(true);
    this->setKeypadEnabled(true);

    return true;
}
开发者ID:duongbadu,项目名称:cocos2dx-sudoku,代码行数:60,代码来源:OptionLayer.cpp

示例4: makeActorImage

void NovelScene::makeActorImage(const char* imageFilePath, int dict)
{
    int dictTag = dict + kTag_ActorDict;
        
    CCSprite* actor = CCSprite::create(imageFilePath);
    actor->setScale(0.75);
        
    removeActorImage(dict);
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    CCPoint point = CCPointZero;
    if (dictTag == kTag_ActorDictLeft)
    {
        point = ccp(actor->boundingBox().size.width * 0.5, actor->boundingBox().size.height * 0.5);
        actor->setFlipX(true);
    }
    else if (dictTag == kTag_ActorDictCenter)
    {     
    }
    else if (dictTag == kTag_ActorDictRight)
    {
        point = ccp(winSize.width - actor->boundingBox().size.width * 0.5, actor->boundingBox().size.height * 0.5);
    }
    actor->setPosition(point);    
    this->addChild(actor, kZOrder_Actor, dictTag);
}
开发者ID:pdpdds,项目名称:cocos2dx-dev,代码行数:26,代码来源:NovelScene.cpp

示例5: onEnter

void TextureAtlasEncryptionDemo::onEnter()
{
    CCLayer::onEnter();
    
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28);
    label->setPosition( ccp(s.width/2, s.height * 0.75f) );
    this->addChild(label, 1);
    
    std::string strSubtitle = subtitle();
    if(strSubtitle.empty() == false)
    {
        CCLabelTTF* subLabel = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16);
        subLabel->setPosition( ccp(s.width/2, s.height-80) );
        this->addChild(subLabel, 1);
    }
    
    // Load the non-encrypted atlas
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Images/nonencryptedAtlas.plist", "Images/nonencryptedAtlas.pvr.ccz");
    
    // Create a sprite from the non-encrypted atlas
    CCSprite *nonencryptedSprite = CCSprite::createWithSpriteFrameName("Icon.png");
    nonencryptedSprite->setPosition(ccp(s.width * 0.25f, s.height * 0.5f));
    this->addChild(nonencryptedSprite);
    
    CCLabelTTF* nonencryptedSpriteLabel = CCLabelTTF::create("non-encrypted", "Arial", 28);
    nonencryptedSpriteLabel->setPosition(ccp(s.width * 0.25f, nonencryptedSprite->boundingBox().getMinY() - nonencryptedSprite->getContentSize().height/2));
    this->addChild(nonencryptedSpriteLabel, 1);
    
    // Load the encrypted atlas
    // 1) Set the encryption keys or step 2 will fail
    // In this case the encryption key 0xaaaaaaaabbbbbbbbccccccccdddddddd is
    // split into four parts. See the header docs for more information.
    ZipUtils::ccSetPvrEncryptionKeyPart(0, 0xaaaaaaaa);
    ZipUtils::ccSetPvrEncryptionKeyPart(1, 0xbbbbbbbb);
    ZipUtils::ccSetPvrEncryptionKeyPart(2, 0xcccccccc);
    ZipUtils::ccSetPvrEncryptionKeyPart(3, 0xdddddddd);
    
    // Alternatively, you can call the function that accepts the key in a single
    // function call.
    // This is slightly less secure because the entire key is more easily
    // found in the compiled source. See the header docs for more information.
    // ZipUtils::ccSetPvrEncryptionKey(0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc, 0xdddddddd);

    // 2) Load the encrypted atlas
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Images/encryptedAtlas.plist", "Images/encryptedAtlas.pvr.ccz");
    
    // 3) Create a sprite from the encrypted atlas
    CCSprite *encryptedSprite = CCSprite::createWithSpriteFrameName("powered.png");
    encryptedSprite->setPosition(ccp(s.width * 0.75f, s.height * 0.5f));
    this->addChild(encryptedSprite);
    
    CCLabelTTF* encryptedSpriteLabel = CCLabelTTF::create("encrypted", "Arial", 28);
    encryptedSpriteLabel->setPosition(ccp(s.width * 0.75f, encryptedSprite->boundingBox().getMinY() - encryptedSpriteLabel->getContentSize().height/2));
    this->addChild(encryptedSpriteLabel, 1);
}
开发者ID:boruis,项目名称:cocos2dx-classical,代码行数:57,代码来源:TextureAtlasEncryptionTest.cpp

示例6: createListViewItem

void StoreAScene::createListViewItem(CCPoint& origin, CCMenu* menu, CCSize& visibleSize, int tag, const char* img) {
	GameMenuItem *pChooseItem = GameMenuItem::itemWithLabel(
		CCSprite::create("button.png"),
					this,
					menu_selector(StoreAScene::menuChooseCallback));

	string itemId = itemIdFromTag(tag);
	
	// TODO: exception handling ..
    string nameS = cocos2dx_StoreInfo::getGoodName(itemId.c_str());
	string infoS = cocos2dx_StoreInfo::getGoodDescription(itemId.c_str());
	int price = cocos2dx_StoreInfo::getGoodPriceForCurrency(itemId.c_str(), "currency_muffin");
	int balance = 0;
	const char * name = nameS.c_str();
	const char * info = infoS.c_str();
	
	float yOffset = - 200;

	pChooseItem->setPosition(ccp(origin.x + visibleSize.width/2, yOffset + origin.y + visibleSize.height - 100 - (tag * pChooseItem->boundingBox().size.height)));
	pChooseItem->setTag(tag);


	CCSprite* pSpritePic = CCSprite::create(img);
	pSpritePic->setPosition(ccp(pSpritePic->boundingBox().size.width/2 + 20, pChooseItem->boundingBox().size.height/2));
	pChooseItem->addChild(pSpritePic, 0);


	CCLabelTTF* pLabelName = CCLabelTTF::create(name, "GoodDog.otf", 44);
	pLabelName->setColor(ccc3(0,0,0));
	pLabelName->setPosition(ccp(pSpritePic->getPositionX() + (pSpritePic->boundingBox().size.width / 2) + (pLabelName->boundingBox().size.width / 2) + 20 , pChooseItem->boundingBox().size.height/2));
	pChooseItem->addChild(pLabelName);


	CCLabelTTF* pLabelInfo = CCLabelTTF::create(info, "GoodDog.otf", 20);
	pLabelInfo->setColor(ccc3(50,50,50));
	pLabelInfo->setPosition(ccp(pSpritePic->getPositionX() + (pSpritePic->boundingBox().size.width / 2) + (pLabelInfo->boundingBox().size.width / 2) + 20 , -50 + (pChooseItem->boundingBox().size.height/2)));
	pChooseItem->addChild(pLabelInfo);


	CCLabelTTF* pLabelClickToBuy = CCLabelTTF::create("Click to Buy", "GoodDog.otf", 24);
	pLabelClickToBuy->setColor(ccc3(0,255,255));
	pLabelClickToBuy->setPosition(ccp(pChooseItem->boundingBox().size.width - (pLabelClickToBuy->boundingBox().size.width / 2) - 20 , 60 + pChooseItem->boundingBox().size.height/2));
	pChooseItem->addChild(pLabelClickToBuy);

	char buffer[512];

	snprintf(buffer, sizeof(buffer), "price: %d blanace: %d",  price, balance);

	goodsPriceBalanceLabels[tag] = CCLabelTTF::create(buffer, "GoodDog.otf", 24);
	goodsPriceBalanceLabels[tag]->setColor(ccc3(0,255,255));
	goodsPriceBalanceLabels[tag]->setPosition(ccp(pChooseItem->boundingBox().size.width - (goodsPriceBalanceLabels[tag]->boundingBox().size.width / 2) - 20 , 60));
	pChooseItem->addChild(goodsPriceBalanceLabels[tag]);

	menu->addChild(pChooseItem, 1);
	
	setPriceBalanceLabel(itemId.c_str());
}
开发者ID:Obg1,项目名称:cocos2dx-store,代码行数:57,代码来源:StoreAScene.cpp

示例7: checkCollision

void HoldOnGame::checkCollision(){
    //小球与障碍物
    CCRect ballRect = playerBall->boundingBox();
    CCRect rect = CCRect(ballRect.origin.x + KBallOffset, ballRect.origin.y + KBallOffset,
                         ballRect.size.width - KBallOffset * 2, ballRect.size.height - KBallOffset * 2);
    for (int i = KBodyTypeRectangleVer; i <= KBodyTypeSquare; i++) {
        CCSprite* sprite = (CCSprite*)gameLayer->getChildByTag(i);
        if (rect.intersectsRect(sprite->boundingBox())) {
            bool over = true;
            
            if (sprite->getTag() == KBodyTypeTriangle) {
                CCRect sRect = sprite->boundingBox();
                CCRect rect1 = CCRect(sRect.origin.x + (sRect.size.width * 0.25) / 2 + KBallOffset, sRect.origin.y,
                                      sRect.size.width * 0.75 - KBallOffset * 2, sRect.size.height * 0.25);
                if (!rect.intersectsRect(rect1)) {
                    rect1 = CCRect(sRect.origin.x + sRect.size.width * 0.25 + KBallOffset, sRect.origin.y + sRect.size.height * 0.25,
                                   sRect.size.width * 0.5 - KBallOffset * 2, sRect.size.height * 0.25);
                    if (!rect.intersectsRect(rect1)) {
                        rect1 = CCRect(sRect.origin.x + sRect.size.width * 3 / 8 + KBallOffset, sRect.origin.y + sRect.size.height * 0.5,
                                       sRect.size.width * 0.25 - KBallOffset* 2, sRect.size.height * 0.25);
                        if (!rect.intersectsRect(rect1)) {
                            rect1 = CCRect(sRect.origin.x + sRect.size.width * 0.45, sRect.origin.y + sRect.size.height * 0.75,
                                           sRect.size.width * 0.1, sRect.size.height * 0.15);
                            if (!rect.intersectsRect(rect1)) {
                                over = false;
                            } else {
                                CCLOG("44444 rect1 = (%.1f, %.1f, %.1f, %.1f)", rect1.origin.x, rect1.origin.y, rect1.size.width, rect1.size.height);
                            }
                        } else {
                            CCLOG("333333 rect1 = (%.1f, %.1f, %.1f, %.1f)", rect1.origin.x, rect1.origin.y, rect1.size.width, rect1.size.height);
                        }
                    } else {
                        CCLOG("22222222 rect1 = (%.1f, %.1f, %.1f, %.1f)", rect1.origin.x, rect1.origin.y, rect1.size.width, rect1.size.height);
                    }
                } else {
                    CCLOG("1111111 rect1 = (%.1f, %.1f, %.1f, %.1f)", rect1.origin.x, rect1.origin.y, rect1.size.width, rect1.size.height);
                }
                
//                if (over) {
//                    CCLOG("rect = (%.1f, %.1f, %.1f, %.1f)", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
//                    CCLOG("sRect = (%.1f, %.1f, %.1f, %.1f)", sRect.origin.x, sRect.origin.y, sRect.size.width, sRect.size.height);
//                    CCLOG("game over");
////                    this->gameOver();
//                    break;
//                }
            }
            
            if (over) {
                this->gameOver();
                break;
            }
        }
    }
}
开发者ID:lkeplei,项目名称:HoldOnGame,代码行数:54,代码来源:HoldOnGame.cpp

示例8: update

void HelloWorld::update(float dt) {

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	float maxX = winSize.width - _ship->getContentSize().width / 2;
	float minX = _ship->getContentSize().width / 2;

	float diff = (_shipPointsPerSecX * dt);
	float newX = _ship->getPosition().x + diff;

	if (_iEnemies == 0) {
		endScene(NEXT);
	}

	newX = MIN(MAX(newX, _minX), _maxX);
	_ship->setPosition(ccp(newX, _ship->getPosition().y));

	// Enemies collision
	CCArray * itAster, itLaser;
	CCObject* item = NULL;
	CCObject* laser_item = NULL;
	CCObject* enemy_laser_item = NULL;
	CCARRAY_FOREACH(_aliens, item)
	{
		CCSprite *enemy = dynamic_cast<CCSprite *>(item);
		if (!enemy->isVisible())
			continue;

		CCARRAY_FOREACH(_shipLasers, laser_item)
		{
			CCSprite *laser = dynamic_cast<CCSprite *>(laser_item);
			if (!laser->isVisible())
				continue;
			CCRect rect = laser->boundingBox();
			if (rect.intersectsRect(enemy->boundingBox())) {
				laser->setVisible(false);
				enemy->setVisible(false);
				_iEnemies--;
				score += level * 10;
				sprintf(points, "Lives: %d Level: %d Score: %d", lives, level,
						score);
				pScoreLabel->setString(points);
				SimpleAudioEngine::sharedEngine()->playEffect(
						"explosion_large.wav");
				//_aliens->removeObject(enemy, false);
				continue;
			}

		}
开发者ID:forsiak,项目名称:SpaceInvaders,代码行数:48,代码来源:HelloWorldScene.cpp

示例9: ccTouchesBegan

void TargetLayer::ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
{
    CCLog("Game State : %d", ((GameScene*)this->getParent())->gameState);
    if ((((GameScene*)this->getParent())->gameState == GAME_ANNOUNCE_LETTER) || ((GameScene*)this->getParent())->gameState == GAME_HIDE) {
        CCTouch* fingerOne = (CCTouch*)pTouches->anyObject();
        CCPoint pointOne = CCDirector::sharedDirector()->convertToUI(fingerOne->getLocationInView());
        CCPoint location = this->convertToNodeSpace(pointOne);
        
        for (int index = 0; index < targets->count(); index++) {
            CCSprite* target = (CCSprite*)targets->objectAtIndex(index);
            
            // Get the Box of the sprite
            CCRect rect = target->boundingBox();
            
            if (rect.containsPoint(location)) {
                
                if (((GameScene*)this->getParent())->gameState == GAME_HIDE) {
                    this->showLetters();
                }
                
                CCLog("Shooted %d", index);
                this->doShoot(target);
                break;
            }
        }
    }
}
开发者ID:JinMyong,项目名称:Language_Russian,代码行数:27,代码来源:TargetLayer.cpp

示例10: ccTouchBegan

bool GameScene::ccTouchBegan(CCTouch *touch, CCEvent *event) {
	if (getBlocksDestroyed() >= BLOCK_COLUMN * BLOCK_ROW) {
		return false;
	}

	CCNode* lavel = dynamic_cast<CCNode*>(this->getChildByTag(kTagStartLabel));
	if (lavel) {
		this->removeChild(lavel, true);
	}

//	CCLog("ccTouchBegan1");
	//現在ボールが飛んでいなければボールを飛ばす
	if (!isTouched) {
		if (UserSettings::getSESetting())
			SimpleAudioEngine::sharedEngine()->playEffect(MP3_BALLPUSH);
		isTouched = true;
		return true;
	}

	CCPoint location = touch->getLocation();
	CCSprite *bar = dynamic_cast<CCSprite*>(this->getChildByTag(kTagBar));
	if (!bar)
		return false;

	//バーの横幅以内がタップされた場合のみタップイベントを有効にする
	bool b = false;
	CCRect rect = bar->boundingBox();
	if (!rect.containsPoint(location)) {
		b = true;
	} else if (location.x >= rect.getMinX() && location.x <= rect.getMaxX()) {
		b = true;
	}
	return b;

}
开发者ID:sakurabird,项目名称:cocos2dx-BlockShooting,代码行数:35,代码来源:GameScene.cpp

示例11: ccTouchesBegan

void GameLayer::ccTouchesBegan(CCSet* touches, CCEvent* event) {
    
    
    
    CCTouch *touch = (CCTouch *)touches->anyObject();
    
    if (touch) {
        
	    CCPoint tap = touch->getLocation();
        CCRect boundary;
        //handle button touches
        CCSprite * button;
        CCSprite * buttonPress;
        
        for (int i = 0; i < 5; i++) {
            button = (CCSprite *) _buttons->objectAtIndex(i);
            if (!button->isVisible()) continue;
            boundary = button->boundingBox();
            
            if (boundary.containsPoint(tap)) {
                buttonPress = (CCSprite *) button->getChildByTag(kSpriteBtnOn);
                buttonPress->setVisible(true);
                return;
            }
        }
    }
    
}
开发者ID:pdpdds,项目名称:cocos2dx-dev,代码行数:28,代码来源:GameLayer.cpp

示例12: deleteSpriteFunc

int TombLayer::deleteSpriteFunc(CCPoint tpoint) {
    // イテレータの取得
	std::list <CCSprite *>::iterator it = enemySpList.begin();
	while (it != enemySpList.end()) {
		// spriteの取得
		CCSprite *pSprite = *it;

        bool isHit=false;
        //タッチ座標の下にspがいるか
        CCRect _rect = pSprite->boundingBox();
        if(_rect.containsPoint(tpoint)){
            isHit=true;
        }
        
        if (isHit) {
            int size=enemySpList.size();
            i_enemyCnt=size-1;
            
            CCLOG("deleteEnemy i_enemyCnt=%d",i_enemyCnt);
            pSprite->stopAllActions();
            // spriteのリストから削除&削除した要素以降のイテレータの取得
			it = enemySpList.erase(it);
            
            //敵の種類によって消すアニメーション
            createEnemydied(pSprite);
            return PT_ENEMY;
            break;
        }else{
            it++;
        }
        
    }//end while

    return 0;
}
开发者ID:tonpachi,项目名称:IDO_no_kaihatu,代码行数:35,代码来源:TombLayer.cpp

示例13: init

bool HSPlayCard::init()
{
    if (!CCNodeRGBA::init()) return false;
    
    // Create frame.
    CCSprite *frame = HS_CREATE_SPRITE(HS_RES_IMG("card_frame"));
    frame->setScale(1.05f);
    frame->setColor(ccc3(200, 200, 200));
    frame->setOpacity(226);
    frame->setTag(TAG_FRAME);
    this->addChild(frame);
    
    // Create text.
    CCLabelTTF *text = CCLabelTTF::create("Now Loading...", "Helvetica", 24.0f,
                                          CCSizeMake(frame->getContentSize().width * 0.95f,
                                                     frame->getContentSize().height * 0.95f),
                                          kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop);
    text->setTag(TAG_MSG);
    this->addChild(text);
    
    // Setup properties.
    this->setContentSize(frame->boundingBox().size);
    
    m_isCompleted = false;
    m_isUpdated = false;
    
    return true;
}
开发者ID:thedoritos,项目名称:TomoMatch,代码行数:28,代码来源:HSPlayCard.cpp

示例14: init

bool UIWidgetAddNodeTest::init()
{
    if (UIScene::init())
    {
        CCSize widgetSize = m_pWidget->getSize();
        
        // Add the alert
        UILabel *alert = UILabel::create();
        alert->setText("Widget Add Node");
        alert->setFontName("Marker Felt");
        alert->setFontSize(30);
        alert->setColor(ccc3(159, 168, 176));
        alert->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f - alert->getSize().height * 1.75));
        m_pUiLayer->addWidget(alert);
        
        // Create the ui node container
        UIWidget* widget = UIWidget::create();
        widget->setPosition(ccp(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
        m_pUiLayer->addWidget(widget);
        
        CCSprite* sprite = CCSprite::create("cocosui/ccicon.png");
        sprite->setPosition(ccp(0, sprite->boundingBox().size.height / 4));
        widget->addNode(sprite);
        
        return true;
    }
    return false;
}
开发者ID:aboduo,项目名称:cocos2dx-classical,代码行数:28,代码来源:UIWidgetAddNodeTest.cpp

示例15: resetMeteor

//use a new meteor from the pool
void GameLayer::resetMeteor(void) {
    if (_fallingObjects->count() > 30) {
        return;
    }
    
    CCSprite * meteor = (CCSprite *) _meteorPool->objectAtIndex(_meteorPoolIndex);
    _meteorPoolIndex++;
    if (_meteorPoolIndex == _meteorPool->count()) {
        _meteorPoolIndex = 0;
    }
    
    int meteor_x = rand() % (int) (_screenSize.width * 0.8f) + _screenSize.width * 0.1f;
    int meteor_target_x = rand() % (int) (_screenSize.width * 0.8f) + _screenSize.width * 0.1f;
    
    meteor->stopAllActions();
    meteor->setPosition(ccp(meteor_x, _screenSize.height + meteor->boundingBox().size.height * 0.5));
    
    CCActionInterval * rotate = CCRotateBy::create(0.5f, -90);
    CCAction * repeatRotate = CCRepeatForever::create(rotate);
    CCFiniteTimeAction * sequence = CCSequence::create(CCMoveTo::create(_meteorSpeed, ccp(meteor_target_x, _screenSize.height * 0.15f)), CCCallFuncN::create(this, callfuncN_selector(GameLayer::fallingObjectDone)), NULL);
    
    meteor->setVisible(true);
    meteor->runAction(repeatRotate);
    meteor->runAction(sequence);
    _fallingObjects->addObject(meteor);
}
开发者ID:ituaijagbone,项目名称:SkyDefense,代码行数:27,代码来源:GameLayer.cpp


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