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


C++ setPositionY函数代码示例

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


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

示例1: getChildByTag

void GamePlay::gameShowMiniBoard() {

	Sprite* miniboard = Sprite::create("miniboard.png");
	miniboard->setPositionX(visibleSize.width / 2);
	miniboard->setPositionY(
			getChildByTag(TAG_LOGO)->getPositionY()
					- getChildByTag(TAG_LOGO)->getBoundingBox().size.height
					- miniboard->getContentSize().height / 2 - PADDING);
	this->addChild(miniboard);

//button replay, resume, share
	MenuItemImage* resumeBtn = MenuItemImage::create("menu_resume.png",
			"menu_resume.png", CC_CALLBACK_0(GamePlay::gameQuit, this));
	auto menuResume = Menu::create(resumeBtn, nullptr);
	menuResume->setPositionY(miniboard->getContentSize().height / 2);
	menuResume->setPositionX(miniboard->getContentSize().width / 2);
	miniboard->addChild(menuResume);

	MenuItemImage* replayBtn = MenuItemImage::create("menu_replay.png",
			"menu_replay.png", CC_CALLBACK_0(GamePlay::gameReplay, this));
	auto menuReplay = Menu::create(replayBtn, nullptr);
	menuReplay->setPositionY(miniboard->getContentSize().height / 2);
	menuReplay->setPositionX(miniboard->getContentSize().width / 4);
	miniboard->addChild(menuReplay);

	MenuItemImage* sharebtn = MenuItemImage::create("menu_share.png",
			"menu_share.png", CC_CALLBACK_0(GamePlay::gameShare, this));
	auto menuShare = Menu::create(sharebtn, nullptr);
	menuShare->setPositionY(miniboard->getContentSize().height / 2);
	menuShare->setPositionX(miniboard->getContentSize().width * 3 / 4);
	miniboard->addChild(menuShare);
}
开发者ID:reddevil138,项目名称:NineGaps,代码行数:32,代码来源:GamePlay.cpp

示例2: onTouchBegan

bool DeckScene::onTouchBegan(Touch * touch, Event * unused_event)
{
	if (!isInGame)
	{
		return false;
	}
	Point point = touch->getLocation();
	for (int i = player->leftCard.size() - 1; i >= 0; i--)
	{
		auto card = player->leftCard.at(i);
		if (card->getBoundingBox().containsPoint(point))
		{
			if (!card->isSelect())
			{
				card->setSelect(true);
				card->setPositionY(card->getPositionY() + cardIntervalVertical);
			}
			else
			{
				card->setSelect(false);
				card->setPositionY(card->getPositionY() - cardIntervalVertical);
			}
			break;
		}
	}
	return true;
}
开发者ID:a364572,项目名称:cocos2dx,代码行数:27,代码来源:DeckScene.cpp

示例3: init

bool GameDisk::init()
{
	if (! Node::init())
	{
		return false;
	}
	//init
	auto bgSpr = Sprite::create("bg.png");
	this->addChild(bgSpr);

	diskSpr = Sprite::create("disk.png");
	this->addChild(diskSpr);

	this->setPosition(DISPLAY_CX, DISPLAY_CY);

	auto buttonNode = Node::create();
	this->addChild(buttonNode);

	auto beginBtn = Sprite::create("arrow_begin.png");
	beginBtn->setPositionY(35);
	buttonNode->addChild(beginBtn);

	auto endBtn = Sprite::create("arrow_end.png");
	endBtn->setPositionY(35);
	buttonNode->addChild(endBtn);

	scheduleUpdate();
	dtAngel = 5.9f;

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

示例4: getUDLR

void BaseCar::lineUpdate(float d)
{
    auto UDLR = getUDLR();

    if (UDLR == right || UDLR == left) {
        _delayedStateName = CarState::Circle;
    }
    auto winSize = Director::getInstance()->getWinSize();
    auto centerPos = Vec2(winSize.width / 2 , winSize.height / 2);
    auto pos = getPosition();

    if ((_direction == Direction::CCW && pos.y > centerPos.y) || (_direction == Direction::CW && pos.y < centerPos.y)) {
        auto newX = pos.x - d * _curVelo;
        setPositionX(newX);
        if (pos.y > centerPos.y) {
            setPositionY(POS_L.y + _curRadius);
        } else {
            setPositionY(POS_L.y - _curRadius);
        }
    }
    else
    {
        auto newX = pos.x + d * _curVelo;
        setPositionX(newX);
        if (pos.y > centerPos.y) {
            setPositionY(POS_L.y + _curRadius);
        } else {
            setPositionY(POS_L.y - _curRadius);
        }
    }
}
开发者ID:FaithZL,项目名称:DontCrash,代码行数:31,代码来源:BaseCar.cpp

示例5: setPositionY

void Star::updatePosition()
{
	if (desPosition.y!=getPositionY())
	{
		setPositionY(getPositionY()-MOVE_SPEED);
		if (getPositionY()<desPosition.y)
		{
		   setPositionY(desPosition.y);
		}
	
	}
	if(desPosition.x != getPositionX()){  
		setPositionX(getPositionX()-MOVE_SPEED);  
		if(getPositionX() < desPosition.x){  
		  setPositionX(desPosition.x);
		}
	}  
	/*if (desPosition.y>getPositionY())
	{
	setPositionY(getPositionY()+MOVE_SPEED);
	if (getPositionY()>desPosition.y)
	{
	setPositionY(desPosition.y);
	}

	}
	if(desPosition.x > getPositionX()){  
	setPositionX(getPositionX()+MOVE_SPEED);  
	if(getPositionX() > desPosition.x){  
	setPositionX(desPosition.x);
	}
	}  */

}
开发者ID:HeHeManuu,项目名称:PopStarByCPP,代码行数:34,代码来源:Star.cpp

示例6: moveBackground

void GameScene::moveBackground(float t) {
    auto bg = this->getChildByTag(100);
    auto bg1 = this->getChildByTag(101);
    
    bg->setPositionY(bg->getPositionY()-2);
    if (bg->getPositionY() < -bg->getContentSize().height) {
        bg->setPositionY(0);
    }
    bg1->setPositionY(bg->getPositionY()+bg->getContentSize().height);
}
开发者ID:Static1014,项目名称:GameTest,代码行数:10,代码来源:GameScene.cpp

示例7: setPositionX

void BaseContentWrapLayer::ccTouchesMoved (CCSet *pTouches, CCEvent *pEvent)
{
	if (!mBaseScene->getCollisionEnable())
	{
		return;
	}

	if (mFixedScaling)
	{
		return;
	}
	
	CCTouch* touch = (CCTouch*)(*(pTouches->begin()));
    if(touch->getID() != 0 || pTouches->count() > 1)
        return;
    
	CCPoint currentPos = touch->getLocation();
	mVCalculate->addTouchMoveRecord(currentPos);

	float x_offset = currentPos.x - mLastTouchPos.x;
	float y_offset = currentPos.y - mLastTouchPos.y;

	setPositionX(getPositionX() + x_offset);
	setPositionY(getPositionY() + y_offset);

	mLastTouchPos = currentPos;

	float min_x;
	float min_y;
	float max_x;
	float max_y;
	getBoarderPos(min_x,min_y,max_x,max_y);

	if (getPositionX() < min_x)
	{
		setPositionX(min_x);
	}
	if (getPositionX() > max_x)
	{
		setPositionX(max_x);
	}

	if (getPositionY() < min_y)
	{
		setPositionY(min_y);
	}
	if (getPositionY() > max_y)
	{
		setPositionY(max_y);
	}
	

}
开发者ID:SongCF,项目名称:game-LostStar,代码行数:53,代码来源:BaseContentWrapLayer.cpp

示例8: if

void PlayScene::moveMapLayer()
{
	//delete
	if (_mapLayerList.front()->getPositionY() + _mapLayerList.front()->getContentSize().height <= 0)
	{
		_mapLayerList.front()->removeFromParent();
		_mapLayerList.pop_front();

		//add
		auto mapLayer = MapLayer::createMap(_totalPoint);
		mapLayer->setAnchorPoint(Vec2(0, 0));
		mapLayer->setPosition(0, 0 + mapLayer->getContentSize().height);

		_mapLayerList.push_back(mapLayer);

		this->addChild(_mapLayerList.back(), 0);
	}

	auto player = this->getChildByName("player");
	float baseLine = _visibleSize.height / 2;

	if (player->getPositionY() > baseLine)
	{
		//Point
		auto up = player->getPositionY() - baseLine;
		_totalPoint += up;

		//auto pointLabel = (LabelTTF*)this->getChildByName("point");
		//pointLabel->setString(String::createWithFormat("%d", _totalPoint)->getCString());

		_mapLayerList.front()->setPositionY(_mapLayerList.front()->getPositionY() - up);
		player->setPositionY(player->getPositionY() - up);
	}
	else if (player->getPositionY() < 0)
	{
		_mapLayerList.front()->setPositionY(_mapLayerList.front()->getPositionY() + abs(player->getPositionY()));
		player->setPositionY(player->getPositionY() + abs(player->getPositionY()));
	}

	//di chuyển map layer phía sau theo
	int count = 0;
	for (std::list<MapLayer*>::iterator it = _mapLayerList.begin(); it != _mapLayerList.end(); it++)
	{
		if (it != _mapLayerList.begin())
		{
			(*it)->setPositionY(_mapLayerList.front()->getPositionY() + _mapLayerList.front()->getContentSize().height * count);
		}
		count++;
	}
}
开发者ID:luuthevinh,项目名称:jump-game,代码行数:50,代码来源:PlayScene.cpp

示例9: setPositionY

void Star::updatePosition(float delta){
	if(desPosition.y != getPositionY()){
		setPositionY(getPositionY() - MOVE_SPEED*delta);
		if(getPositionY() < desPosition.y){
			setPositionY(desPosition.y);
		}
	}
	if(desPosition.x != getPositionX()){
		setPositionX(getPositionX() - MOVE_SPEED*delta);
		if(getPositionX() < desPosition.x){
			setPositionX(desPosition.x);
		}
	}
}
开发者ID:joyfish,项目名称:cocos2d,代码行数:14,代码来源:Star.cpp

示例10: backgroundMove

/* 背景滚动的回调方法 */
void GameMenuScene::backgroundMove(float f)
{
    // 背景滚动逻辑
    auto bg1 = this->getChildByTag(101);
    auto bg2 = this->getChildByTag(102);
    // 当第二张图片退出屏幕时,把第一张图片设置到屏幕中,
    // 由于背景图片的高度是大于屏幕的高度的,所以判断逻辑要复杂点
    if (bg2 -> getPositionY() + bg2->getContentSize().height <=
            Director::getInstance()->getVisibleSize().height) {
        bg1->setPositionY(-bg1->getContentSize().height +
                                  Director::getInstance()->getVisibleSize().height);
    }
    bg1->setPositionY(bg1->getPositionY() - 3);
    bg2->setPositionY(bg1->getPositionY() + bg1->getContentSize().height);
}
开发者ID:azliqiang,项目名称:Cocos2D-X,代码行数:16,代码来源:GameMenuScene.cpp

示例11: switch

void Dummy::updateSelf( const double & delta )
{
	switch( state() )
	{
		case SPAWNING:
		{
			setPosition( randomPointOnWorld( world() ) + QVector3D(0,10,0) );
			setState( ALIVE );
			setLife( 100 );
			mHeightAboveGround = 6.0f;
			break;
		}

		case ALIVE:
		{
			mTarget = world()->teapot()->worldPosition();
			QVector3D directionToTarget = ( mTarget - worldPosition() ).normalized();
			QQuaternion targetRotation = Quaternion::lookAt( directionToTarget, QVector3D(0,1,0) );
			setRotation( QQuaternion::slerp( rotation(), targetRotation, 0.05 ) );
			setPosition( position() + direction()*delta*10.0 );
			if( life() <= 0 )
				setState( DYING );
			break;
		}

		case DYING:
			setState( DEAD );
			mHeightAboveGround = 3.0f;
			break;

		case DEAD:
			break;
	}

	mVelocityY += -3.0f * delta;	// apply some gravity
	setPositionY( position().y() + mVelocityY * delta );

	float landscapeHeight;
	if( world()->landscape()->terrain()->getHeight( position(), landscapeHeight ) )
	{
		if( landscapeHeight + mHeightAboveGround > position().y() )
		{
			setPositionY( landscapeHeight + mHeightAboveGround );
			if( mVelocityY < 0.0f )
				mVelocityY = 0.0f;
		}
	}
}
开发者ID:splatterlinge,项目名称:Splatterlinge,代码行数:48,代码来源:Dummy.cpp

示例12: setPositionX

void UiTextBox::update(){
	if(m_Camera){
		setPositionX(m_Camera->getWorldPosX()+m_ScreenPosX);
		setPositionY(m_Camera->getWorldPosY()+m_ScreenPosY);
		m_Text->setPosition(getPositionX(),getPositionY());
	}
}
开发者ID:StevenBryar,项目名称:BlobeGameLevelEditor,代码行数:7,代码来源:uiTextBox.cpp

示例13: setPositionY

void BossBullet::update(){
	setPositionY(getPositionY()-3);
	timecounter1++;
	if (timecounter1 >= 300){
		remove = true;
	}
}
开发者ID:JohnKavanagh1050,项目名称:Bawse-Phighter-Android,代码行数:7,代码来源:BossBullet.cpp

示例14: OctopusBaby

SODOctopus::SODOctopus(Panel* container, GridOctopus* gridO, Spell* s, SpellTarget* target)
	: OctopusBaby(int(gridO->getCellDimensions().x*1.5), int(gridO->getCellDimensions().y*5)), _grid(gridO), _spell(s), _target(target)
{	
	Texture t = (*ServiceLocator::getTextureManager())["SwordDestiny"];
	Point d = gridO->getCellDimensions() * 3;
	// compute ratio
	double ratiox = (double)d.x / t.getWidth();
	double ratioy = (double)d.y / t.getHeight();
	ratio = min(ratioy, ratiox);

	unsigned int n = target->getCell()->getNumber();
	Point cellCenter = gridO->getCellCenter(n);
	
	width = int(t.getWidth() * ratio);
	height = int(t.getHeight() * ratio);

	container->add(this);
	Point pos = toContainerCoordinates(gridO->toAbsoluteCoordinates(Point(cellCenter.x - width / 2, cellCenter.y - height - d.y/3)));

	ori_pos = pos;
	dst_pos = toContainerCoordinates(gridO->toAbsoluteCoordinates(Point(cellCenter.x - width / 2, cellCenter.y - height)));

	setPositionX((int)pos.x);
	setPositionY((int)pos.y);

	setBgColor(Color::TRANSPARENT);
	setActive(true);
	beginTime = TIMESERVICE->time();
	finishTime = beginTime + totalTime;

	setZIndex(gridO->getZIndexFromCell(n) + 1);
}
开发者ID:TinyMan,项目名称:warfare-of-heroes,代码行数:32,代码来源:SODOctopus.cpp

示例15: initButton

void CompleteMissionScene::initButton()
{
	Size visibleSize = Director::getInstance()->getVisibleSize();
	int MemberNum = 10;
	int MissionNum = MissionManager::getInstance()->getMissionSize(MissionCondition::COMPLETION);
	int revision = 0;

	for (int i = 0; i < MissionNum; i++)
	{
		Mission mission = MissionManager::getInstance()->getMission(MissionCondition::COMPLETION,i);

		auto menuitem = ui::Button::create("res/MissionButton.png");
		menuitem->addTouchEventListener(CC_CALLBACK_2(CompleteMissionScene::MissionButtonCallback, this));
		menuitem->setAnchorPoint(Point(0, 0));
		menuitem->setTag(MissionButtonList.size());
		menuitem->setName("MISSION_FUNCTION");
		this->getChildByName("MISSION_SCROLLVIEW")->addChild(menuitem);

		if (8 > MissionNum)
		{
			revision = 7 - MissionNum;
		}

		menuitem->setPositionY(MissionNum
			* 40 - 40 * i - 40 + revision * 40);
		MissionButtonList.push_back(menuitem);

		auto missionName = Label::createWithSystemFont(mission.name, "Thonburi", 24, Size::ZERO,
			TextHAlignment::LEFT);
		missionName->setColor(Color3B(0, 0, 0));
		missionName->setPosition(110, 20);
		menuitem->addChild(missionName);
		
	}
}
开发者ID:Hunnywind,项目名称:BigGuild,代码行数:35,代码来源:CompleteMissionScene.cpp


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