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


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

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


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

示例1: clickXilianJingHua

void ZhuangbeiXilianUI::clickXilianJingHua(CCObject *obj)
{
	if (m_dInfoDialog)
	{
		m_dInfoDialog->removeFromParent();
		m_dInfoDialog = NULL;
	}
	string tishiStr = LFStrings::getValue("XilianJingHuaShuoMing");
	string cailiaoFileStr = "daoju_youlanzhiye.png";

	//弹框背景
	BaseSprite* dialog = BaseSprite::create("gongjiang_duanzao_cailiaobuzu_tanchukuang.png");
	dialog->setPosition(ccp(mWinSize.width/2, mWinSize.height/2 + 50));
	//提示
	{
		BaseSprite *cailiaoBg = BaseSprite::create("daoju_kuang_bg.png");
		dialog->addChild(cailiaoBg);
		cailiaoBg->setPosition(ccp(cailiaoBg->getContentSize().width/2 + 10, dialog->getContentSize().height/2));
		BaseSprite *cailiaoImg = BaseSprite::create(cailiaoFileStr);
		cailiaoBg->addChild(cailiaoImg);
		cailiaoImg->setPosition(ccp(cailiaoBg->getContentSize().width/2, cailiaoBg->getContentSize().height/2));

		CCLabelTTF* lable = CCLabelTTF::create(tishiStr.c_str(), fontStr_kaiti,20,CCSize(240, 0), kCCTextAlignmentLeft);
		dialog->addChild(lable);
		lable->setAnchorPoint(ccp(0,0.5));
		lable->setPosition(ccp(cailiaoBg->getPositionX()+cailiaoBg->getContentSize().width/2 , dialog->getContentSize().height/2));
	}
	//按键
	CCMenu* menu = CCMenu::create();
	{
		CCMenuItemImage* item = CCMenuItemImage::create(
			"gongjiang_duanzao_cailiaobuzu_tanchukuang.png",
			"gongjiang_duanzao_cailiaobuzu_tanchukuang.png",
			this, menu_selector(ZhuangbeiXilianUI::clickCiaoliaoShuoMing));
		menu->addChild(item);
		item->setPosition(ccp(dialog->getContentSize().width/2, dialog->getContentSize().height/2));
		item->setOpacity(0);
		item->setScaleX(mWinSize.width / dialog->getContentSize().width);
		item->setScaleY(mWinSize.height / dialog->getContentSize().height);
		// 		item->setScaleX(mWinSize.width / item->getContentSize().width);
		// 		item->setScaleY(mWinSize.height / item->getContentSize().height);
	}
	//弹框
	{

		LFAlert* lfAlert = new LFAlert();
		lfAlert->setBaseContainer(dialog,menu);
		CCDirector::sharedDirector()->getRunningScene()->addChild(lfAlert,128);
		lfAlert->release();
		m_dInfoDialog = lfAlert;
	}
}
开发者ID:longguai,项目名称:game-DarkWar,代码行数:52,代码来源:ZhuangbeiXilianUI.cpp

示例2: createPillar

CCMenuItemImage* HelloWorld::createPillar(int posX, int tag)
{
	CCMenu* menu = CCMenu::create();
	CCMenuItemImage* pillar = CCMenuItemImage::create("/pillar.png","/pillar.png",this,menu_selector(HelloWorld::selectPillar));
	pillar->setScaleX(float(0.2));
	pillar->setScaleY(float(0.4));
	pillar->setPosition(ccp(posX,-75));
	pillar->setTag(tag);
	pillar->setEnabled(false);
	menu->setTag(tag);
	menu->addChild(pillar);
	this->addChild(menu);
	return pillar;
}
开发者ID:brandav,项目名称:CPlusPlus_Code,代码行数:14,代码来源:Hanoi.cpp

示例3: init

// on "init" you need to initialize your instance
bool JoinLayer::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    //    double dScalX = size.width / 768 , dScalY= size.height / 1024;
    CCSprite* backgroundView = CCSprite::create("[email protected]");
    backgroundView->setPosition(ccp(size.width / 2, size.height / 2));
    float scale_x = size.width / backgroundView->getContentSize().width;
    float scale_y = size.height / backgroundView->getContentSize().height;
    backgroundView->setScaleX(scale_x);
    backgroundView->setScaleY(scale_y);
    addChild(backgroundView);
    
    CCSprite* spCharacter = CCSprite::create("[email protected]");
    spCharacter->setPosition(ccp(size.width / 2, size.height / 2));
    spCharacter->setScaleX(scale_x);
    spCharacter->setScaleY(scale_y);
    addChild(spCharacter);
    
    CCSprite* spLogo = CCSprite::create("[email protected]");
    spLogo->setPosition(ccp(size.width / 2 , getY(size.height, 304, 71) * scale_y));
    spLogo->setScaleX(scale_x);
    spLogo->setScaleY(scale_y);
    addChild(spLogo);
    
    CCSprite* spAdBanner = CCSprite::create("[email protected]");
    spAdBanner->setPosition(ccp(size.width / 2 , getY(size.height, 50, 910) * scale_y));
    spAdBanner->setScaleX(scale_x);
    spAdBanner->setScaleY(scale_y);
    addChild(spAdBanner);
    
    CCMenuItemImage *playButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(JoinLayer::onClickPlay));
    playButton->setPosition(ccp(size.width / 2, getY(size.height, 152, 664)));
    playButton->setScaleX(scale_x);
    playButton->setScaleY(scale_y);
    
    CCMenu* menu = CCMenu::create(playButton,NULL);
    menu->setPosition(CCPointZero);
    addChild(menu);
    
    return true;
}
开发者ID:tianyang1993,项目名称:Sneaker-Match-Mania-Android,代码行数:49,代码来源:JoinLayer.cpp

示例4:

CCMenuItemImage* Objects2dFactory::imageButton(CCNode* scene, CCMenu* menu, string normalImagePath, string selectedImagePath, string disabledImagePath, 
	float positionX, float positionY, float width, float height, SEL_MenuHandler selector, void* selectorArg, AlignX alignX, AlignY alignY, int zOrder)
{
	// Check arguments validity
	if(scene == NULL || menu == NULL || !selector)
		return NULL;

	// Create a button menu item
    CCMenuItemImage *button = CCMenuItemImage::create(
        normalImagePath.c_str(),
        selectedImagePath.c_str(),
        disabledImagePath.c_str(),
        scene,
        selector);
    if(!button)
		return NULL;

	if (selectorArg != NULL)
	{
		button->setUserData(selectorArg);
	}

    // Place the menu item in the given position
    button->setPosition(ccp(positionX, positionY));

	// Set anchor
	button->setAnchorPoint(ccp(Constants::getAnchorValue(alignX), Constants::getAnchorValue(alignY)));
	
	// Set menu item width
	float buttonWidth = button->boundingBox().size.width;
	if (width > 0) // if width is defined, it is setted
	{
		button->setScaleX(width / buttonWidth);
	}

	// Set menu item height
	float buttonHeight = button->boundingBox().size.height;
	if (height > 0) // if height is defined, it is setted
	{
		button->setScaleY(height / buttonHeight);
	}

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

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

示例5: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback) );
    pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition( CCPointZero );
    this->addChild(pMenu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    CCLabelTTF* pLabel = CCLabelTTF::create("Cocos2dx GreePlatform Binding Test", "Thonburi", 34);

    // ask director the window size
    CCSize size = CCDirector::sharedDirector()->getWinSize();

    // position the label on the center of the screen
    pLabel->setPosition( ccp(size.width / 2, size.height - 20) );

    // add the label as a child to this layer
    this->addChild(pLabel, 1);

    // add "HelloWorld" splash screen"
    pSprite = CCSprite::create("HelloWorld.png");

    // position the sprite on the center of the screen
    pSprite->setPosition( ccp(size.width/2, size.height/2) );

    // add the sprite as a child to this layer
    this->addChild(pSprite, 0);

	// GreeButton
	pGreeButtonText = CCLabelTTF::create("Log in", "Thonburi", 34);
	pGreeButtonText->setPosition(ccp(size.width - 100, size.height - 40));
	this->addChild(pGreeButtonText, 1);
	CCMenuItemImage *pGree = CCMenuItemImage::create("gree.png", "gree.png", this, menu_selector(HelloWorld::menuGreeButtonCallback));
	pGree->setPosition(ccp(size.width - 100, size.height - 100));
	CCMenu* pGreeMenu = CCMenu::create(pGree, NULL);
	this->addChild(pGreeMenu, 1);
	pGreeMenu->setPosition(CCPointZero);
	pGree->setScaleY(3.0);
	pGree->setScaleX(3.0);		

    return true;
}
开发者ID:8823-scholar,项目名称:GreePlatformSDKCocos2dx,代码行数:66,代码来源:HelloWorldScene.cpp

示例6: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    
    CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
    
    // position the label on the center of the screen
    pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - pLabel->getContentSize().height));

    // add the label as a child to this layer
    this->addChild(pLabel, 1);

    // add "HelloWorld" splash screen"
    CCSprite* pSprite = CCSprite::create("HelloWorld.png");

    // position the sprite on the center of the screen
    pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

    // add the sprite as a child to this layer
    this->addChild(pSprite, 0);
    
    this->setKeypadEnabled(true);
    
    
    CCMenuItemImage *pItemPlay = CCMenuItemImage::create(
                                                         "playgameNormal.png", "playgameClose.png",this,menu_selector(HelloWorld::menuPlayGameCallback));
    pItemPlay->setPosition(ccp(visibleSize.width / 2, visibleSize.height*1.0f / 4.0f));
    pItemPlay->setScaleX(visibleSize.width / 600);
    pItemPlay->setScaleY(visibleSize.height / 400);
    
    CCMenu *pMenuPlay = CCMenu::create(pItemPlay, NULL);
    pMenuPlay->setPosition(CCPointZero);
    this->addChild(pMenuPlay, 1);
    
    CCSprite *pcSprite  = CCSprite::create("ScenceStart.png");
    pcSprite->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
    CCSize sz = pSprite->getContentSize();
    pcSprite->setScaleX(visibleSize.width / sz.width);
    pcSprite->setScaleY(visibleSize.height / sz.height);
    this->addChild(pcSprite, 0);
    
    return true;
}
开发者ID:k8802810,项目名称:cocos2dx_tank,代码行数:78,代码来源:HelloWorldScene.cpp

示例7: init

bool MenuScene::init()
{
	if(!CCLayer::init())
	{
		return false;
	}
	//播放背景音乐
	AudioEngine::sharedEngine()->playBackgroundMusic("sounds/0.mp3",true);
	//获取窗口大小
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	//创建精灵
	CCSprite* sprite = CCSprite::create("btn/menubg1.png");
	//让背景的大小与窗口一样
	sprite->setScaleX(winSize.width/sprite->getContentSize().width);
	sprite->setScaleY(winSize.height/sprite->getContentSize().height);
	//位置
	sprite->setPosition(ccp(winSize.width/2,winSize.height/2));
	//把精灵添加进场景里
	this->addChild(sprite);
	
	//////////////////////////////////////////////////////////
	//单机模式
	CCMenuItemImage* singleGame = CCMenuItemImage::create(
		"btn/startbtn_normal.png",
		"btn/startbtn_touched.png",
		this,
		menu_selector(MenuScene::singleGameCallBack));

	singleGame->setScaleY((winSize.height/singleGame->getContentSize().height*0.15));
	singleGame->setScaleX((winSize.width /singleGame->getContentSize().width)*0.15);
	

	CCMenu* pMenu1 = CCMenu::create(singleGame,NULL);
	pMenu1->setPosition(ccp(winSize.width/2,winSize.height/2));
	
	this->addChild(pMenu1, 2);

	CCSprite* start = CCSprite::create("btn/text_start.png");

	start->setScaleX(winSize.width/start->getContentSize().width*0.1);
	start->setScaleY(winSize.height/start->getContentSize().height*0.07);
	start->setPosition(ccp(winSize.width/2,winSize.height/2));
	this->addChild(start,3);
	
	//////////////////////////////////////////////////////////
	//退出
	CCMenuItemImage* quit = CCMenuItemImage::create(
		"btn/startbtn_normal.png",
		"btn/startbtn_touched.png",
		this,
		menu_selector(MenuScene::quitCallBack));

	quit->setScaleY((winSize.height/quit->getContentSize().height*0.15));
	quit->setScaleX((winSize.width /quit->getContentSize().width)*0.15);


	CCMenu* pMenu2 = CCMenu::create(quit,NULL);
	pMenu2->setPosition(ccp(winSize.width/2,winSize.height/2*0.5));

	this->addChild(pMenu2, 2);

	CCSprite* quitImage = CCSprite::create("btn/quit.png");

	quitImage->setScaleX(winSize.width/quitImage->getContentSize().width*0.1);
	quitImage->setScaleY(winSize.height/quitImage->getContentSize().height*0.07);
	quitImage->setPosition(ccp(winSize.width/2,winSize.height/2*0.5));
	this->addChild(quitImage,3);

	//auto audioEngine=AudioEngine::getInstance();
	//audioEngine->playEffect("sounds/1000.ogg");

	
	return true;
}
开发者ID:keyor,项目名称:doudizhu,代码行数:74,代码来源:MenuScene.cpp

示例8: init

bool MainView::init(){
    
    if (!CCLayer::init()) {
        return false;
    }
    size = CCDirector::sharedDirector()->getWinSize();
//    dScaleFactorX = size.width / 768, dScaleFactorY = size.height / 1024;
//    FirstGame = false;
    
//    gameSettings = GameSettings::sharedGameSettings();
   
    
    // ChartBoost SDK Integration
    
//    ChartboostX::sharedChartboostX()->setDelegate(this);
//    this->ShowChartBoost();
//    
//    
//    int first =  CCUserDefault::sharedUserDefault()->getIntegerForKey("first");
//    if (first == 1) {
//       
//        FirstGame = false;
//        
//    }else{
//        FirstGame = true;
//        CCUserDefault::sharedUserDefault()->setIntegerForKey("first", 1);
//        CCUserDefault::sharedUserDefault()->setBoolForKey("effectSound", true);
//        CCUserDefault::sharedUserDefault()->setBoolForKey("backgroundSound" , true);
//        gameSettings->setBackGround(1);
//        gameSettings->setBackGroundMusic(1);
//        gameSettings->setCurrentStatus(kTagNonStatus);
//        gameSettings->setPlayed(false);
//   
//    }
//    
//    setBackGroundView(gameSettings->getBackground());
//
//    int nType = gameSettings->getBackgroundMusic();
// 
//    if (!gameSettings->isPlayed()) {
//        gameSettings->playBackGround(nType);
//    }
//    
//    showMainView();
    
    CCSprite* backgroundView = CCSprite::create("[email protected]");
    backgroundView->setPosition(ccp(size.width / 2, size.height / 2));
    float scale_x = size.width / backgroundView->getContentSize().width;
    float scale_y = size.height / backgroundView->getContentSize().height;
    backgroundView->setScaleX(scale_x);
    backgroundView->setScaleY(scale_y);
    addChild(backgroundView);

    CCSprite* spCharacter = CCSprite::create("[email protected]");
    spCharacter->setPosition(ccp(size.width / 2, size.height / 2));
    spCharacter->setScaleX(scale_x);
    spCharacter->setScaleY(scale_y);
    addChild(spCharacter);

    CCSprite* spLogo = CCSprite::create("[email protected]");
    spLogo->setPosition(ccp(size.width / 2 , getY(size.height, 304, 71) * scale_y));
    spLogo->setScaleX(scale_x);
    spLogo->setScaleY(scale_y);
    addChild(spLogo);

    CCSprite* spAdBanner = CCSprite::create("[email protected]");
    spAdBanner->setPosition(ccp(size.width / 2 , getY(size.height, 50, 910) * scale_y));
    spAdBanner->setScaleX(scale_x);
    spAdBanner->setScaleY(scale_y);
    addChild(spAdBanner);

    
    CCMenuItemImage *facebookButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(MainView::onClickFacebookButton));
    facebookButton->setPosition(ccp(size.width / 2, getY(size.height, 132, 596)));
    facebookButton->setScaleX(scale_x);
    facebookButton->setScaleY(scale_y);

    CCMenuItemImage *guestButton = CCMenuItemImage::create("[email protected]", "[email protected]", this, menu_selector(MainView::onClickGuestButton));
    guestButton->setPosition(ccp(size.width / 2, getY(size.height, 132, 756)));
    guestButton->setScaleX(scale_x);
    guestButton->setScaleY(scale_y);
    
    CCMenu* menu = CCMenu::create(facebookButton,guestButton,NULL);
    menu->setPosition(CCPointZero);
    addChild(menu);

    return true;
}
开发者ID:tianyang1993,项目名称:Sneaker-Match-Mania-Android,代码行数:88,代码来源:MainView.cpp


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