• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setPosition函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: img

vmain::vmain() : img(NULL){
	setSize(283,342);
	setPosition(800/2-283/2,600/2-342/2);
	setMovable(false);
	setTitleBarHeight(0);
	setPadding(0);
	setFocusable(false);
	login_added=false;

	/*puerto= new _TextField("7666",gcn::Graphics::CENTER);
	puerto->setSize(133,14);
	puerto->setBackgroundColor(gcn::Color(0,0,0,0));
	puerto->setForegroundColor(gcn::Color(255,255,255,255));
	puerto->setBorderSize(0);
	add(puerto,200,163);*/

	/*host= new _TextField("testserver.aonx.com.ar",gcn::Graphics::CENTER);
	host->setSize(208,14);
	host->setBackgroundColor(gcn::Color(0,0,0,0));
	host->setForegroundColor(gcn::Color(255,255,255,255));
	host->setBorderSize(0);
	add(host,366,163);*/

	/*blogin = new NoDrawButton;
	blogin->setSize(230,80);
	blogin->setFocusable(false);
	blogin->setActionEventId("blogin");
	blogin->addActionListener(this);

	add(blogin,560,340);*/

	/*bcreate = new NoDrawButton;
	bcreate->setSize(230,80);
	bcreate->setFocusable(false);
	bcreate->setActionEventId("CREATE");
	bcreate->addActionListener(ClienteArgentum::instancia());

	add(bcreate,560,440);*/

	login_button = new ImageButton();
	create_button = new ImageButton();
	servers_button = new ImageButton();
	options_button = new ImageButton();
	exit_button = new ImageButton();

	login_button->setSize(250, 40);
	create_button->setSize(250, 40);
	servers_button->setSize(250, 40);
	options_button->setSize(250, 40);
	exit_button->setSize(250, 40);
	
	std::string path;
	path=ConfigData::GetPath("gui") + std::string("main_menu/");

	login_button->setNormalImage(path + std::string("login.png"));
	login_button->setMoserOverImage(path + std::string("loginb.png"));
	login_button->setActionEventId("LOGIN_DIALOG");
	login_button->addActionListener(ClienteArgentum::instancia());

	create_button->setNormalImage(path + std::string("create.png"));
	create_button->setMoserOverImage(path + std::string("createb.png"));
	create_button->setActionEventId("CREATE");
	create_button->addActionListener(ClienteArgentum::instancia());

	servers_button->setNormalImage(path + std::string("servers.png"));
	servers_button->setMoserOverImage(path + std::string("serversb.png"));

	options_button->setNormalImage(path + std::string("opciones.png"));
	options_button->setMoserOverImage(path + std::string("opcionesb.png"));
	options_button->setActionEventId("OPTIONS");
	options_button->addActionListener(ClienteArgentum::instancia());

	exit_button->setNormalImage(path + std::string("salir.png"));
	exit_button->setMoserOverImage(path + std::string("salirb.png"));
	exit_button->setActionEventId("EXIT");
	exit_button->addActionListener(ClienteArgentum::instancia());

	add(login_button,17, 66);
	add(create_button,17, 121);
	add(servers_button,17, 176);
	add(options_button,17, 231);
	add(exit_button,17, 287);


}
开发者ID:DakaraOnline,项目名称:AONX,代码行数:85,代码来源:vmain.cpp


示例2: setPosition

void Widget::setLeft( int newLeft )
{
  setPosition( Point( newLeft, getTop() ) );    
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:4,代码来源:oc3_widget.cpp


示例3: updateQuantityLabel

////////////////////////////////////////////////////////
//
// ParticleMainScene
//
////////////////////////////////////////////////////////
void ParticleMainScene::initWithSubTest(int asubtest, int particles)
{
    //srandom(0);

    subtestNumber = asubtest;
    auto s = Director::getInstance()->getWinSize();

    lastRenderedCount = 0;
    quantityParticles = particles;

    MenuItemFont::setFontSize(65);
    auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) {
		quantityParticles -= kNodesIncrease;
		if( quantityParticles < 0 )
			quantityParticles = 0;

		updateQuantityLabel();
		createParticleSystem();
	});
    decrease->setColor(Color3B(0,200,20));
    auto increase = MenuItemFont::create(" + ", [&](Ref *sender) {
		quantityParticles += kNodesIncrease;
		if( quantityParticles > kMaxParticles )
			quantityParticles = kMaxParticles;

		updateQuantityLabel();
		createParticleSystem();
	});
    increase->setColor(Color3B(0,200,20));

    auto menu = Menu::create(decrease, increase, NULL);
    menu->alignItemsHorizontally();
    menu->setPosition(Vec2(s.width/2, s.height/2+15));
    addChild(menu, 1);

    auto infoLabel = Label::createWithTTF("0 nodes", "fonts/Marker Felt.ttf", 30);
    infoLabel->setColor(Color3B(0,200,20));
    infoLabel->setPosition(Vec2(s.width/2, s.height - 90));
    addChild(infoLabel, 1, kTagInfoLayer);

    // particles on stage
    auto labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.');
    addChild(labelAtlas, 0, kTagLabelAtlas);
    labelAtlas->setPosition(Vec2(s.width-66,50));

    // Next Prev Test
    auto menuLayer = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx);
    addChild(menuLayer, 1, kTagMenuLayer);
    menuLayer->release();

    // Sub Tests
    MenuItemFont::setFontSize(40);
    auto pSubMenu = Menu::create();
    for (int i = 1; i <= 6; ++i)
    {
        char str[10] = {0};
        sprintf(str, "%d ", i);
        auto itemFont = MenuItemFont::create(str, CC_CALLBACK_1(ParticleMainScene::testNCallback, this));
        itemFont->setTag(i);
        pSubMenu->addChild(itemFont, 10);

        if (i <= 3)
        {
            itemFont->setColor(Color3B(200,20,20));
        }
        else
        {
            itemFont->setColor(Color3B(0,200,20));
        }
    }
    pSubMenu->alignItemsHorizontally();
    pSubMenu->setPosition(Vec2(s.width/2, 80));
    addChild(pSubMenu, 2);

    auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32);
    addChild(label, 1);
    label->setPosition(Vec2(s.width/2, s.height-50));

    updateQuantityLabel();
    createParticleSystem();

    schedule(schedule_selector(ParticleMainScene::step));
}
开发者ID:289997171,项目名称:cocos2d-x,代码行数:88,代码来源:PerformanceParticleTest.cpp


示例4: setPosition

void TextCursor::setPosition(const KTextEditor::Cursor& position)
{
    setPosition(position, false);
}
开发者ID:dividedmind,项目名称:kate,代码行数:4,代码来源:katetextcursor.cpp


示例5: setPosition

void AutoTank::moveTo(TVector newPosition)
{
	setPosition(newPosition.X(), newPosition.Y(), newPosition.Z());
	currentPosition.setY(terrain->GetHeight((float)currentPosition.X(), (float)currentPosition.Z()) + 6.4);
}
开发者ID:54UL,项目名称:openGL-tankgame,代码行数:5,代码来源:AutoTank.cpp


示例6: setPosition

void BasicScreenObject::setX(float _x) {
  setPosition(_x, getY(), getZ());
}
开发者ID:kitschpatrol,项目名称:ofxRRScenegraph,代码行数:3,代码来源:BasicScreenObject.cpp


示例7: setPosition

void Sprite::setCurrentFrame(u16 animID, u16 frameID) {
	setPosition(m_animations.at(animID).getFramePosition(frameID).x,
	            m_animations.at(animID).getFramePosition(frameID).y);

	setCurrentFrame(m_animations.at(animID).getFrame(frameID));
}
开发者ID:Quent42340,项目名称:ZeldaOOL,代码行数:6,代码来源:Sprite.cpp


示例8: CRRCDialog


//.........这里部分代码省略.........
  }
  mapgroup->close();
  mapgroup->hide();

  // The combo box above the "mapping group"
  combo_radiotype = new puaComboBox(LABEL_W + DLG_DEF_SPACE,
                                   BUTTON_BOX_HEIGHT + (NUM_FUNCTIONS)* DLG_DEF_SPACE + (NUM_FUNCTIONS) * INPUT_H,
                                   LABEL_W + DLG_DEF_SPACE + COMBO_W,
                                   BUTTON_BOX_HEIGHT + (NUM_FUNCTIONS)* DLG_DEF_SPACE + (NUM_FUNCTIONS + 1) * INPUT_H,
                                   NULL, false);
  combo_radiotype->setChildColourScheme(PUCLASS_POPUPMENU, dlgCol1[0], dlgCol1[1], dlgCol1[2]);
  combo_radiotype->newList(radioTypes);
  combo_radiotype->setLabelPlace(PUPLACE_CENTERED_LEFT);
  combo_radiotype->setLabel(_("Radio type"));
  combo_radiotype->setUserData(this);
  combo_radiotype->setCurrentItem(Global::TXInterface->map->radioType());
  combo_radiotype->setCallback(CGUIComboCallback);

  if (combo_radiotype->getCurrentItem() == T_AxisMapper::CUSTOM)
  {
    mapgroup->reveal();
  }

  if ((Global::TXInterface->inputMethod() == T_TX_Interface::eIM_mouse)
        ||
      (Global::TXInterface->inputMethod() == T_TX_Interface::eIM_joystick))
  {
    Global::TXInterface->map->setRadioType(T_AxisMapper::CUSTOM);
    combo_radiotype->setCurrentItem(Global::TXInterface->map->radioType());
    combo_radiotype->hide();
  }
  else
  {
    combo_radiotype->reveal();
  }
  
  // The "calibration group" (right part of the dialog).
  calibgroup = new puGroup(LABEL_W + 3*DLG_DEF_SPACE + DLG_CHECK_W + INPUT_W + HORIZ_SPACER,
                           BUTTON_BOX_HEIGHT + DLG_DEF_SPACE);
  
  for (int i = 0; i < TX_MAXAXIS; i++)
  {
    axis[i] = new puSlider( i*SLIDER_SP + i * SLIDER_W,
                            LABEL_H + DLG_DEF_SPACE + DLG_DEF_BUTTON_HEIGHT,
                            SLIDER_SZ,
                            TRUE,
                            SLIDER_W);
    axis[i]->setLabelPlace(PUPLACE_BOTTOM_CENTERED);
    axis[i]->setLabel(axislabel[i]);
    axis[i]->setValue((float)0.5);
    
    // set min and max to some excessive values
    minval[i] = 1.0e30;
    maxval[i] = -1.0e30;
  }
  
  butCalibrate = new puOneShot( 0,
                                0,
                                DLG_DEF_BUTTON_WIDTH + 10,
                                DLG_DEF_BUTTON_HEIGHT);
  butCalibrate->setLegend(_("Calibrate"));
  butCalibrate->setLabelPlace(PUPLACE_BOTTOM_LEFT);
  butCalibrate->setLabel("");
  butCalibrate->setUserData(this);
  butCalibrate->setCallback(CGUICalibButtonCallback);
  
  if (Global::TXInterface->usesCalibration())
  {
    butCalibrate->reveal();
  }
  else
  {
    butCalibrate->hide();
  }

  calibgroup->close();

  close();
  
  //resize
  setSize(LABEL_W + (TX_MAXAXIS -1)*SLIDER_SP + DLG_DEF_SPACE+ DLG_CHECK_W + INPUT_W + 2*HORIZ_SPACER + TX_MAXAXIS * SLIDER_W,
          BUTTON_BOX_HEIGHT + (NUM_FUNCTIONS+3) * DLG_DEF_SPACE + (NUM_FUNCTIONS+1) * INPUT_H);
  
  
  setCallback(CGUICalibMapCallback);

  // center the dialog on screen
  int wwidth, wheight;
  int current_width = getABox()->max[0] - getABox()->min[0];
  int current_height = getABox()->max[1] - getABox()->min[1];
  puGetWindowSize(&wwidth, &wheight);
  setPosition(wwidth/2 - current_width/2, wheight/2 - current_height/2);
  
  //set the dialogue transparent  and hide the others dialogues to better see the model
  setTransparency(.3);
  hideOthers();
  
  reveal();

}
开发者ID:KISSMonX,项目名称:crrcsim-pprz,代码行数:101,代码来源:crrc_calibmap.cpp


示例9: setPosition

YInfoJumpListRecord::YInfoJumpListRecord(const QString & filename, const QPoint pos)
{
    mFilename = filename;
    setPosition(pos);
}
开发者ID:sandsmark,项目名称:yzis,代码行数:5,代码来源:yzisinfojumplistrecord.cpp


示例10: insertCodeSnippet

void TextDocumentManipulator::insertCodeSnippet(int position, const QString &text)
{
    auto cursor = m_textEditorWidget->textCursor();
    cursor.setPosition(position, QTextCursor::KeepAnchor);
    m_textEditorWidget->insertCodeSnippet(cursor, text);
}
开发者ID:DuinoDu,项目名称:qt-creator,代码行数:6,代码来源:textdocumentmanipulator.cpp


示例11: setPosition

bool Explosive::doAction(float _f)
{
#ifdef						GOLDEN_MINER_2_VERSION_TIME
	statusTimeCount += _f;
	double _positionX = 0;
	double _positionY = 0;
	float _ratio = (GRENADE_TIME/60.0 - statusTimeCount) / (GRENADE_TIME/60.0);
	if (_ratio < 0)
	{
		_ratio = 0;
	}
	if(hanger->carryTargetType == GAMECONTROL_TYPE_TARGET_STATIC)
	{
		_positionX = ((Target *)hanger->carryTargetPoint)->getPositionX() + (Global::getInstance()->getcentreX() - ((Target *)hanger->carryTargetPoint)->getPositionX()) * _ratio;
		_positionY = ((Target *)hanger->carryTargetPoint)->getPositionY() + (Global::getInstance()->getcentreY() - ((Target *)hanger->carryTargetPoint)->getPositionY()) * _ratio;
		setPosition(ccp(_positionX, _positionY));
	}
	else if (hanger->carryTargetType == GAMECONTROL_TYPE_TARGET_DYNAMIC)
	{
		if (((DynamicTarget *)hanger->carryTargetPoint)->getId() == DYNAMIC_ID_SHELL)
		{
			_positionX = ((DynamicTargetShell *)hanger->carryTargetPoint)->shellSprite->getPositionX() + (Global::getInstance()->getcentreX() - ((DynamicTarget *)hanger->carryTargetPoint)->getArmature()->getPositionX()) * _ratio;
			_positionY = ((DynamicTargetShell *)hanger->carryTargetPoint)->shellSprite->getPositionY() + (Global::getInstance()->getcentreY() - ((DynamicTarget *)hanger->carryTargetPoint)->getArmature()->getPositionY()) * _ratio;
		}
		else
		{
			_positionX = ((DynamicTarget *)hanger->carryTargetPoint)->getArmature()->getPositionX() + (Global::getInstance()->getcentreX() - ((DynamicTarget *)hanger->carryTargetPoint)->getArmature()->getPositionX()) * _ratio;
			_positionY = ((DynamicTarget *)hanger->carryTargetPoint)->getArmature()->getPositionY() + (Global::getInstance()->getcentreY() - ((DynamicTarget *)hanger->carryTargetPoint)->getArmature()->getPositionY()) * _ratio;
		}
		setPosition(ccp(_positionX, _positionY));
	}
	else
	{
		return true;
	}
	if ((statusTimeCount >= GRENADE_TIME/60.0)&& ((statusTimeCount - _f) >= GRENADE_TIME/60.0))
	{
		return true;
		//releaseSkills(SKILL_ID_GRENADE);	
	}
#else
	statusTimeCount++;
	double _positionX = 0;
	double _positionY = 0;
	if(hanger->carryTargetType == GAMECONTROL_TYPE_TARGET_STATIC)
	{
		_positionX = ((Target *)hanger->carryTargetPoint)->getPositionX() + (Global::getInstance()->getcentreX() - ((Target *)hanger->carryTargetPoint)->getPositionX()) * (GRENADE_TIME - statusTimeCount) / GRENADE_TIME;
		_positionY = ((Target *)hanger->carryTargetPoint)->getPositionY() + (Global::getInstance()->getcentreY() - ((Target *)hanger->carryTargetPoint)->getPositionY()) * (GRENADE_TIME - statusTimeCount) / GRENADE_TIME;
		setPosition(ccp(_positionX, _positionY));
	}
	else if (hanger->carryTargetType == GAMECONTROL_TYPE_TARGET_DYNAMIC)
	{
		if (((DynamicTarget *)hanger->carryTargetPoint)->getId() == DYNAMIC_ID_SHELL)
		{
			_positionX = ((DynamicTargetShell *)hanger->carryTargetPoint)->shellSprite->getPositionX() + (Global::getInstance()->getcentreX() - ((DynamicTarget *)hanger->carryTargetPoint)->getArmature()->getPositionX()) * (GRENADE_TIME - statusTimeCount) / GRENADE_TIME;
			_positionY = ((DynamicTargetShell *)hanger->carryTargetPoint)->shellSprite->getPositionY() + (Global::getInstance()->getcentreY() - ((DynamicTarget *)hanger->carryTargetPoint)->getArmature()->getPositionY()) * (GRENADE_TIME - statusTimeCount) / GRENADE_TIME;
		}
		else
		{
			_positionX = ((DynamicTarget *)hanger->carryTargetPoint)->getArmature()->getPositionX() + (Global::getInstance()->getcentreX() - ((DynamicTarget *)hanger->carryTargetPoint)->getArmature()->getPositionX()) * (GRENADE_TIME - statusTimeCount) / GRENADE_TIME;
			_positionY = ((DynamicTarget *)hanger->carryTargetPoint)->getArmature()->getPositionY() + (Global::getInstance()->getcentreY() - ((DynamicTarget *)hanger->carryTargetPoint)->getArmature()->getPositionY()) * (GRENADE_TIME - statusTimeCount) / GRENADE_TIME;
		}
		setPosition(ccp(_positionX, _positionY));
	}
	else
	{
		return true;
	}
	if (statusTimeCount == GRENADE_TIME)
	{
		return true;
		//releaseSkills(SKILL_ID_GRENADE);	
	}
#endif
	return false;
}
开发者ID:wjf1616,项目名称:TheMiners,代码行数:76,代码来源:Explosive.cpp


示例12: setPosition

void OrthoViewControllerCustom::lookAt( const Ogre::Vector3& point )
{
  setPosition( point - target_scene_node_->getPosition() );
}
开发者ID:team-vigir,项目名称:vigir_ocs_common,代码行数:4,代码来源:ortho_view_controller_custom.cpp


示例13: clearTrajectory

void clearTrajectory() {
    setPosition(0, 0, 0);
    lastLeft = 0.0f;
    lastRight = 0.0f;
    lastAngle = 0.0f;
}
开发者ID:hternier,项目名称:cen-electronic,代码行数:6,代码来源:trajectory.c


示例14: setPosition

void Bullet::move(float dt) {
    setPosition(cocos2d::Vec2(getPositionX() + (velocity.x*dt),
                            getPositionY() + (velocity.y*dt)));
}
开发者ID:BKO,项目名称:Space-Shooter,代码行数:4,代码来源:Bullet.cpp


示例15: setPosition

void HeroFrog::setCurPosition(Point pos){
    setPosition(pos);
    if (pos.x - downPoint.x>=0) {
        setHeroStatus(frogJumpDown);
    }
}
开发者ID:haohongxian77,项目名称:parabola-x,代码行数:6,代码来源:HeroFrog.cpp


示例16: windowSize

void LevelSelectState::addLevel(LevelData lData, const std::string &map, bool enabled){

    sf::Vector2f windowSize(getContext().window->getSize());
    auto levelButton = std::make_shared<GUI::ContainerButton>(
         *getContext().textureManager);

    levelButton->setCallback(
        [this, map]() {
            requestStackPop();
            requestStackPush(State::ID::Loading, map);
        });

    GUI::Label::Ptr levelLabel;
    if (enabled){
        levelLabel = std::make_shared<GUI::Label>(
            lData.name,
            sf::Color::Black,
            28,
            *getContext().fontManager);

        GUI::Label::Ptr timeLabel;
        std::ostringstream timeStream;
        timeStream << lData.bestTime;
        timeLabel = std::make_shared<GUI::Label>(
            timeStream.str(),
            sf::Color::Black,
            32,
            *getContext().fontManager);
    }
    else{
        levelLabel = std::make_shared<GUI::Label>(
            lData.name,
            sf::Color(0,0,0,100),
            32,
            *getContext().fontManager);
        levelButton->disable();
    }  
    levelLabel->setOrigin(0.f, levelLabel->getOrigin().y);

    GUI::Label::Ptr timeLabel;

    if (lData.bestTime > 0.0f){
        std::ostringstream timeStream;
        timeStream << lData.bestTime;
        timeLabel = std::make_shared<GUI::Label>(
            timeStream.str(),
            sf::Color::Black,
            32,
            *getContext().fontManager);
    }
    else{
        std::ostringstream timeStream;
        timeStream << lData.bestTime;
        timeLabel = std::make_shared<GUI::Label>(
            timeStream.str(),
            sf::Color(0,0,0,100),
            32,
            *getContext().fontManager);
    }

    GUI::Number::Ptr numGems = std::make_shared<GUI::Number>(
        *getContext().textureManager, static_cast<unsigned int>(lData.requiredGems));

    sf::Texture &HUDTexture = getContext().textureManager->get(TextureID::HUDSpriteSheet);
    sf::IntRect rect;

    if (lData.collectedGem)
        rect = sf::IntRect(98, 185, 46, 36);
    else
        rect = sf::IntRect(98, 97, 46, 36);
    GUI::Image::Ptr gem = std::make_shared<GUI::Image>(
        HUDTexture, rect);

    if (lData.badgeEarned)
        rect = sf::IntRect(54, 49, 48, 48);
    else
        rect = sf::IntRect(54, 0, 48, 48);
    GUI::Image::Ptr badge = std::make_shared<GUI::Image>(
        HUDTexture, rect);
    
    levelButton->add(levelLabel);
    levelButton->add(timeLabel);
    levelButton->add(numGems);
    levelButton->add(gem);
    levelButton->add(badge);
    mLevelContainer->add(levelButton);
    float posX = windowSize.x * 0.5f;
    float firstButtonPadding = windowSize.y / 2.f - mLevelPanel.getGlobalBounds().height / 2.f + 100.f;
    float posY = static_cast<float>(firstButtonPadding + 100 * numLevels);
    levelButton->setPosition(posX, posY);
    
    levelLabel->move(-270, -10);
    timeLabel->move(0, -10);
    timeLabel->move(280, 0);
    numGems->move(-330, 0);
    gem->move(130, 0);
    badge->move(180, 0);

    ++numLevels;
}
开发者ID:TylerSandman,项目名称:marvin,代码行数:100,代码来源:LevelSelectState.cpp


示例17: sprintf

void GameOver::update(float dt)
{
    
    
    second = second + 1;
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    
     if(second == 1)
    {
        std::string pass_pic = "over/over.png";
        auto gameover_pass_pic = Sprite::create(pass_pic);
        gameover_pass_pic->setPosition(Vec2(origin.x + visibleSize.width/2-20,
                                            origin.y + visibleSize.height/2+150));
        this->addChild(gameover_pass_pic,103);
        /*
        auto gameover_score = Sprite::create("setting/gameoverscore.png");
        gameover_score->setPosition(Vec2(origin.x + visibleSize.width/2,
                                         origin.y + visibleSize.height/2+200));
        
        
        this->addChild(gameover_score,102);
        
        auto score_all = CCLabelTTF::create("",  "American Typewriter", 60);
        score_all->setColor(cocos2d::Color3B(100, 60, 60));
        score_all->retain();
        score_all->setPosition(origin.x + visibleSize.width/2+33,
                               origin.y + visibleSize.height/2+200);
        char str_1[100];
        sprintf(str_1, " %d ", score_this);
        score_all->setString(str_1);
        score_all->setVisible(true);
        this->addChild(score_all, 103);
        
        */
        
        
    }else if(second == 5)
    {
        auto tryAgainItem = MenuItemImage::create(
                                                  "setting/tryagain.png",
                                                  "setting/tryagain.png",
                                                  CC_CALLBACK_1(GameOver::menuTryAgainItemCallback, this));
        
        tryAgainItem->setPosition(Vec2(origin.x + visibleSize.width/2,
                                       origin.y + visibleSize.height/2));
    
        
        auto gameoverShareItem = MenuItemImage::create(
                                                       "setting/gameovershare.png",
                                                       "setting/gameovershare.png",
                                                       CC_CALLBACK_1(GameOver::menuGameoverShareItemCallback, this));
        
        gameoverShareItem->setPosition(Vec2(origin.x + visibleSize.width/2-250 ,
                                            origin.y + visibleSize.height/2-250));
        
        auto gameoverCommentItem = MenuItemImage::create(
                                                         "setting/gameovercomment.png",
                                                         "setting/gameovercomment.png",
                                                         CC_CALLBACK_1(GameOver::menuGameoverCommentItemCallback, this));
        
        gameoverCommentItem->setPosition(Vec2(origin.x + visibleSize.width/2+250 ,
                                              origin.y + visibleSize.height/2-250));
        
       auto backItem = MenuItemImage::create(
                                             "setting/backtomenu.png",
                                             "setting/backtomenu.png",
                                              CC_CALLBACK_1(GameOver::menuBackItemCallback, this));
        
        backItem->setPosition(Vec2(origin.x + visibleSize.width/2 ,
                                   origin.y + visibleSize.height/2-250));
        
        
        
        //auto menu = Menu::create(tryAgainItem, gameoverShareItem, gameoverCommentItem, backItem, NULL);
        auto menu = Menu::create(tryAgainItem, gameoverShareItem, gameoverCommentItem,backItem, NULL);
        menu->setPosition(Vec2::ZERO);
        this->addChild(menu,103);
        
    }
     
    
}
开发者ID:kimikimi911,项目名称:growup,代码行数:83,代码来源:GameOver.cpp


示例18: CC_CALLBACK_1

//------------------------------------------------------------------
//
// MenuLayer4
//
//------------------------------------------------------------------
MenuLayer4::MenuLayer4()
{
    MenuItemFont::setFontName("American Typewriter");
    MenuItemFont::setFontSize(18);
    auto title1 = MenuItemFont::create("Sound");
    title1->setEnabled(false);
    MenuItemFont::setFontName( "fonts/Marker Felt.ttf" );
    MenuItemFont::setFontSize(34);
    auto item1 = MenuItemToggle::createWithCallback( CC_CALLBACK_1(MenuLayer4::menuCallback, this),
                 MenuItemFont::create( "On" ),
                 MenuItemFont::create( "Off"),
                 nullptr );

    MenuItemFont::setFontName( "American Typewriter" );
    MenuItemFont::setFontSize(18);
    auto title2 = MenuItemFont::create( "Music" );
    title2->setEnabled(false);
    MenuItemFont::setFontName( "fonts/Marker Felt.ttf" );
    MenuItemFont::setFontSize(34);
    auto item2 = MenuItemToggle::createWithCallback(CC_CALLBACK_1(MenuLayer4::menuCallback, this),
                 MenuItemFont::create( "On" ),
                 MenuItemFont::create( "Off"),
                 nullptr );

    MenuItemFont::setFontName( "American Typewriter" );
    MenuItemFont::setFontSize(18);
    auto title3 = MenuItemFont::create( "Quality" );
    title3->setEnabled( false );
    MenuItemFont::setFontName( "fonts/Marker Felt.ttf" );
    MenuItemFont::setFontSize(34);
    auto item3 = MenuItemToggle::createWithCallback(CC_CALLBACK_1(MenuLayer4::menuCallback, this),
                 MenuItemFont::create( "High" ),
                 MenuItemFont::create( "Low" ),
                 nullptr );

    MenuItemFont::setFontName( "American Typewriter" );
    MenuItemFont::setFontSize(18);
    auto title4 = MenuItemFont::create( "Orientation" );
    title4->setEnabled(false);
    MenuItemFont::setFontName( "fonts/Marker Felt.ttf" );
    MenuItemFont::setFontSize(34);
    auto item4 = MenuItemToggle::createWithCallback(CC_CALLBACK_1(MenuLayer4::menuCallback, this),
                 MenuItemFont::create( "Off" ),
                 nullptr );

    // TIP: you can manipulate the items like any other MutableArray
    item4->getSubItems().pushBack( MenuItemFont::create( "33%" ) );
    item4->getSubItems().pushBack( MenuItemFont::create( "66%" ) );
    item4->getSubItems().pushBack( MenuItemFont::create( "100%" ) );

    // you can change the one of the items by doing this
    item4->setSelectedIndex( 2 );

    MenuItemFont::setFontName( "fonts/Marker Felt.ttf" );
    MenuItemFont::setFontSize( 34 );

    auto label = Label::createWithBMFont("fonts/bitmapFontTest3.fnt",  "go back");
    auto back = MenuItemLabel::create(label, CC_CALLBACK_1(MenuLayer4::backCallback, this) );

    auto menu = Menu::create(
                    title1, title2,
                    item1, item2,
                    title3, title4,
                    item3, item4,
                    back, nullptr ); // 9 items.

    menu->alignItemsInColumns(2, 2, 2, 2, 1, NULL);

    addChild( menu );

    auto s = Director::getInstance()->getWinSize();
    menu->setPosition(Vec2(s.width/2, s.height/2));
}
开发者ID:zengzhining,项目名称:cocos2d-x,代码行数:78,代码来源:MenuTest.cpp


示例19: Image

HiddenMask::HiddenMask(unsigned int width, unsigned int height, int x, int y)// : Image(width, height)
{
    setPosition({x, y});
}
开发者ID:g4th,项目名称:falltergeist,代码行数:4,代码来源:HiddenMask.cpp


示例20: CC_CALLBACK_2

//------------------------------------------------------------------
//
// MenuLayerMainMenu
//
//------------------------------------------------------------------
MenuLayerMainMenu::MenuLayerMainMenu()
{
    _touchListener = EventListenerTouchOneByOne::create();
    _touchListener->setSwallowTouches(true);
    _touchListener->onTouchBegan = CC_CALLBACK_2(MenuLayerMainMenu::onTouchBegan, this);
    _touchListener->onTouchMoved = CC_CALLBACK_2(MenuLayerMainMenu::onTouchMoved, this);
    _touchListener->onTouchEnded = CC_CALLBACK_2(MenuLayerMainMenu::onTouchEnded, this);
    _touchListener->onTouchCancelled = CC_CALLBACK_2(MenuLayerMainMenu::onTouchCancelled, this);

    _eventDispatcher->addEventListenerWithFixedPriority(_touchListener, 1);

    // Font Item
    auto spriteNormal = Sprite::create(s_MenuItem, Rect(0,23*2,115,23));
    auto spriteSelected = Sprite::create(s_MenuItem, Rect(0,23*1,115,23));
    auto spriteDisabled = Sprite::create(s_MenuItem, Rect(0,23*0,115,23));

    auto item1 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, CC_CALLBACK_1(MenuLayerMainMenu::menuCallback, this) );

    // Image Item
    auto item2 = MenuItemImage::create(s_SendScore, s_PressSendScore, CC_CALLBACK_1(MenuLayerMainMenu::menuCallback2, this) );

    // Label Item (LabelAtlas)
    auto labelAtlas = LabelAtlas::create("0123456789", "fonts/labelatlas.png", 16, 24, '.');
    auto item3 = MenuItemLabel::create(labelAtlas, CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackDisabled, this) );
    item3->setDisabledColor( Color3B(32,32,64) );
    item3->setColor( Color3B(200,200,255) );
    CCLOG("test MenuItem Label getString: %s", item3->getString().c_str());
    // Font Item
    auto item4 = MenuItemFont::create("I toggle enable items", [&](Ref *sender) {
        _disabledItem->setEnabled(! _disabledItem->isEnabled() );
    });

    item4->setFontSizeObj(20);
    item4->setFontName("fonts/Marker Felt.ttf");

    // Label Item (LabelBMFont)
    auto label = Label::createWithBMFont("fonts/bitmapFontTest3.fnt", "configuration");
    auto item5 = MenuItemLabel::create(label, CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackConfig, this));

    // Testing issue #500
    item5->setScale( 0.8f );

    // Events
    MenuItemFont::setFontName("fonts/Marker Felt.ttf");
    // Bugs Item
    auto item6 = MenuItemFont::create("Bugs", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackBugsTest, this));

    // Font Item
    auto item7= MenuItemFont::create("Quit", CC_CALLBACK_1(MenuLayerMainMenu::onQuit, this));

    auto item8 = MenuItemFont::create("Remove menu item when moving", CC_CALLBACK_1(MenuLayerMainMenu::menuMovingCallback, this));

    auto color_action = TintBy::create(0.5f, 0, -255, -255);
    auto color_back = color_action->reverse();
    auto seq = Sequence::create(color_action, color_back, nullptr);
    item7->runAction(RepeatForever::create(seq));

    auto menu = Menu::create( item1, item2, item3, item4, item5, item6, item7, item8,  nullptr);
    menu->alignItemsVertically();


    // elastic effect
    auto s = Director::getInstance()->getWinSize();

    int i=0;
    for(const auto &child : menu->getChildren()) {
        auto dstPoint = child->getPosition();
        int offset = (int) (s.width/2 + 50);
        if( i % 2 == 0)
            offset = -offset;

        child->setPosition( Vec2( dstPoint.x + offset, dstPoint.y) );
        child->runAction(
            EaseElasticOut::create(MoveBy::create(2, Vec2(dstPoint.x - offset,0)), 0.35f)
        );
        i++;
    }

    _disabledItem = item3;
    item3->retain();
    _disabledItem->setEnabled( false );

    addChild(menu);
    menu->setPosition(Vec2(s.width/2, s.height/2));
    menu->setScale(0);
    menu->runAction(ScaleTo::create(1,1));
}
开发者ID:zengzhining,项目名称:cocos2d-x,代码行数:92,代码来源:MenuTest.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setPositionY函数代码示例发布时间:2022-05-30
下一篇:
C++ setPosVar函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap