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


C++ CCMenuItemImage::getPosition方法代码示例

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


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

示例1: init

// on "init" you need to initialize your instance
bool CLoginScene::init()
{
	bool bRet = false;
	do 
	{
		//////////////////////////////////////////////////////////////////////////
		// super init first
		//////////////////////////////////////////////////////////////////////////

		CC_BREAK_IF(! CCLayer::init());

		// 1. Add a menu item with "X" image, which is clicked to quit the program.

		// Create a "close" menu item with close icon, it's an auto release object.
		CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(
			"Resources/ForNum_Normal.png",
			"Resources/ForNum_Select.png",
			this,
			menu_selector(CLoginScene::menuCloseCallback));
		CC_BREAK_IF(! pCloseItem);

		// Place the menu item bottom-right conner.
		pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, CCDirector::sharedDirector()->getWinSize().height / 2));

		CCLabelTTF* pNumLabel = CCLabelTTF::labelWithString("Play Soduko", "Thonburi", 24);
		CC_BREAK_IF(! pNumLabel);

		pNumLabel->setPosition(pCloseItem->getPosition());
		this->addChild(pNumLabel, 3);

		// Create a menu with the "close" menu item, it's an auto release object.
		CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
		pMenu->setPosition(CCPointZero);
		CC_BREAK_IF(! pMenu);

		// Add the menu to HelloWorld layer as a child layer.
		this->addChild(pMenu, 1);

		CCDirector::sharedDirector()->setDepthTest(true);

		bRet = true;
	} while (0);

	return bRet;
}
开发者ID:JayKingston,项目名称:StupidTest,代码行数:46,代码来源:LoginScene.cpp

示例2: init

bool RankingScene::init() {
    CCSprite *background = CCSprite::create("BackGround2.png");
    background->setPosition(ccp(w/2, h/2));
    this->addChild(background);
    //-------------- menu getperesent ---------------
    CCMenuItemImage *bt_send_email  = CCMenuItemImage::create("Present.png","Present.png",
                                this, menu_selector(RankingScene::clickBtSendEmail));
        bt_send_email->setPosition(ccp(w/4, h/8.2 + 20));
    CCHttpRequest* request = new CCHttpRequest();
    string ipAddr = GameManager::sharedGameManager()->getIpAddr();
    request->setUrl((ipAddr+":3000/users.json").c_str());
    request->setRequestType(CCHttpRequest::kHttpGet);
    request->setResponseCallback(this, callfuncND_selector(RankingScene::onHttpRequestCompleted));
    CCHttpClient::getInstance()->send(request);
    request->release();
    
    //create startMenuItem
    CCMenuItemImage *playItem =
        CCMenuItemImage::create("StartButton.png", "StartButton.png",
                                this, menu_selector(RankingScene::play));
    playItem->setPosition(ccp(w/2, h/8));
    playItem->setScale(0.7f);
    //create bgmItem
    CCMenuItemImage *bgmItem =
        CCMenuItemImage::create("BgmOn.png", "BgmOn.png",
                                this, menu_selector(RankingScene::bgm));
    bgmItem->setPosition(ccp(w*4/5, h/8));
    CCMenu* pMenu = CCMenu::create(playItem, bgmItem, bt_send_email, NULL);
    pMenu->setPosition(ccp(0,0));
    this->addChild(pMenu);
    bgm_off = CCSprite::create("BgmOff.png");
    bgm_off->setPosition(bgmItem->getPosition());
    bgm_off->setVisible(GameManager::sharedGameManager()->getBgm());
    if (GameManager::sharedGameManager()->getBgm()) {
        SimpleAudioEngine::sharedEngine()->setEffectsVolume(0.0f);
    } else {
        SimpleAudioEngine::sharedEngine()->setEffectsVolume(1.0f);
    }
    this->addChild(bgm_off);
    
        
    return true;
}
开发者ID:ngocdu,项目名称:AirHockey2,代码行数:43,代码来源:RankingScene.cpp

示例3: init

bool RankingScene::init() {
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	w = size.width;
    h = size.height;
    players = new CCArray();
    CCSprite *background = CCSprite::create("BackGrounds/BackGround2.png");
    background->setPosition(ccp(w/2, h/2));
    this->addChild(background);
    
    CCSprite *topLine = CCSprite::create("line.png");
    topLine->setPosition(ccp(w/2, 602));
    topLine->setOpacity(70);
    this->addChild(topLine);
    
    CCSprite *bottomLine = CCSprite::create("line.png");
    bottomLine->setPosition(ccp(w/2, 248));
    bottomLine->setOpacity(70);
    this->addChild(bottomLine);
    //-------------- menu getperesent ---------------
    
    
    CCMenuItemImage *reward  =
        CCMenuItemImage::create("Present.png","PresentOnClicked.png",
                                this, menu_selector(RankingScene::reward));
    reward->setPosition(ccp(w/5, h/8));

    string playerName = GameManager::sharedGameManager()->getName();
    if (playerName == "") reward->setVisible(false);
    
    CCHttpRequest* request = new CCHttpRequest();
    string ipAddr = GameManager::sharedGameManager()->getIpAddr();
    request->setUrl((ipAddr+":3000/users.json").c_str());
    request->setRequestType(CCHttpRequest::kHttpGet);
    request->setResponseCallback(this, callfuncND_selector(RankingScene::onHttpRequestCompleted));
    CCHttpClient::getInstance()->send(request);
    request->release();
    
    //create startMenuItem
    CCMenuItemImage *playItem =
        CCMenuItemImage::create("Buttons/StartButton.png", "Buttons/StartButtonOnClicked.png",
                                this, menu_selector(RankingScene::play));
    playItem->setPosition(ccp(w/2, h/8 - 10));
    //create bgmItem
    CCMenuItemImage *bgmItem =
        CCMenuItemImage::create("BgmOn.png", "BgmOn.png",
                                this, menu_selector(RankingScene::bgm));
    bgmItem->setPosition(ccp(w*4/5, h/8));
    CCMenu* pMenu = CCMenu::create(playItem, bgmItem, reward, NULL);
    pMenu->setPosition(ccp(0,0));
    this->addChild(pMenu);
    

    bgm_off = CCSprite::create("BgmOff.png");
    bgm_off->setPosition(bgmItem->getPosition());
    bgm_off->setVisible(GameManager::sharedGameManager()->getBgm());
    if (GameManager::sharedGameManager()->getBgm()) {
        SimpleAudioEngine::sharedEngine()->setEffectsVolume(0.0f);
    } else {
        SimpleAudioEngine::sharedEngine()->setEffectsVolume(1.0f);
    }
    this->addChild(bgm_off);
    
        
    return true;
}
开发者ID:ngocdu,项目名称:AirHockeyAndroid,代码行数:65,代码来源:RankingScene.cpp

示例4: moveBlock

void HelloWorld::moveBlock()
{
	int pPillar = 20; // prior pillar (block-containing pillar)
	int newTopBlock = 20;
	CCMenuItemImage* pillar = ((CCMenuItemImage*)(this->getChildByTag(selectedPillar)->getChildByTag(selectedPillar)));
	CCMenuItemImage* block = ((CCMenuItemImage*)(this->getChildByTag(selectedBlock)->getChildByTag(selectedBlock)));

	// disable pillars, set to default
	for (int i=0 ; i<3 ; i++)
	{
		//((CCMenuItemImage*)((this->getChildByTag(i))->getChildByTag(i)))->setEnabled(false);
		//((CCMenuItemImage*)((this->getChildByTag(i))->getChildByTag(i)))->setOpacity(255);
		// determine block-containing pillar via boundingBox containsPoint fxn
		if (((CCMenuItemImage*)(this->getChildByTag(i)->getChildByTag(i)))->boundingBox().containsPoint(block->getPosition()) == true)
		{
			//CCLog("block-containing pillar is %i",i);
			pPillar = i;
			break;
		}
	}

	// loop through blocks for belowBlock
	float belowBlock = block->getPositionY() - bHeight;
	for (int x=3 ; x<10 ; x++)
	{
		if (((CCMenuItemImage*)((this->getChildByTag(x))->getChildByTag(x)))->boundingBox().containsPoint(ccp(block->getPositionX(),belowBlock)) == true)
		{
			//CCLog("belowBlock is block tag %i",x);
			newTopBlock = x;
			break;
		}
	}
	block->setPosition(ccp(pillar->getPositionX(),(-150+(bHeight*numBlock[selectedPillar]))));
	
	// add to number of blocks on selectedPillar
	numBlock[selectedPillar]++;
	//CCLog("pillar %i has %i blocks",selectedPillar,numBlock[selectedPillar]);
	
	// subtract number of blocks from priorPillar
	numBlock[pPillar]--;
	//CCLog("pillar %i has %i blocks",pPillar,numBlock[pPillar]);
	
	// set topBlock for selectedPillar
	topBlock[selectedPillar] = selectedBlock;
	//CCLog("pillar %i's top block is tag %i",selectedPillar,selectedBlock);
	
	// set topBlock for priorPillar
	topBlock[pPillar] = newTopBlock;
	//CCLog("pillar %i's top block is tag %i",pPillar,newTopBlock);
}
开发者ID:brandav,项目名称:CPlusPlus_Code,代码行数:50,代码来源:Hanoi.cpp


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