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

C++ setPositionY函数代码示例

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

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



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


示例16: onEnter

void WelcomeScene::onEnter(){
    Layer::onEnter();
    
    auto bg = Sprite::createWithSpriteFrameName("BattleCity.png");
    bg->setPosition(VisibleRect::bottom());
    bg->setScale(2);
    this->addChild(bg);
    
    
    auto item1 = MenuItemFont::create("进入游戏", [=](Ref*ref){
        auto _scene = GameScene::createScene();
        Director::getInstance()->replaceScene(_scene);
    });
    item1->setPosition(VisibleRect::center());
    item1->setPositionY(item1->getPositionY()-100);
    auto _menu = Menu::create(item1,NULL);
    _menu->setPosition(0,0);
    _menu->setVisible(false);
    this->addChild(_menu);
    
    auto _moveBy = MoveBy::create(1, Vec2(0, 400));
    auto _callFunc = CallFuncN::create([=](Ref*ref){
            _menu->setVisible(true);
    });
    bg->runAction(Sequence::create(_moveBy,_callFunc, NULL));
    
    
    
    
}
开发者ID:hostbrian,项目名称:BattleCity,代码行数:30,代码来源:WelcomeScene.cpp


示例17: setPositionX

void b2Sprite::update(float dt){
    if (_body && isVisible()) {
        setPositionX(_body->GetPosition().x * PTM_RATIO);
        setPositionY(_body->GetPosition().y * PTM_RATIO);
        setRotation(CC_RADIANS_TO_DEGREES(-1 * _body->GetAngle()));
    }
}
开发者ID:bacph178,项目名称:AirHockey-MultiPlaform,代码行数:7,代码来源:b2Sprite.cpp


示例18: Collisionable

	Pipe::Pipe(const std::string& textureName,
			Vector2f& position,
			int indexPipeDestination, 
			const std::string& levelDestination, 
			State state, 
			int lenght, 
			Direction direction, 
			Monster* monster)
			: Collisionable("textures/pipes/" + textureName, position), 
			_indexDestination(indexPipeDestination), 
			_levelDestination(levelDestination), 
			_state(state), 
			_lenght(lenght), 
			_direction(direction), 
			_monster(monster),
			_monsterExitDuration(Clock())
	{
		_hitboxPosition.x = position.x;
		_hitboxPosition.y = position.y;

		setPositionX(position.x);
		setPositionY(position.y);

		_hitboxSize.x = _texture->getSize().x;
		_hitboxSize.y = (_texture->getSize().y / 2 * _lenght) + _texture->getSize().y / 2;
	}
开发者ID:MORTAL2000,项目名称:super-mario-project,代码行数:26,代码来源:Pipe.cpp


示例19: sprintf

void GameCharacterShape::floatNumber(int num, GameCharacterShape::FloatNumberTypeEnum type )
{
    char numStr[10];
    sprintf(numStr, "-%d", num);
    // 选择使用的文字样式
    auto tmpFntSrc  =   "";
    switch (type)
    {
    case GameCharacterShape::FLOAT_NUMBER_GREEN:
        tmpFntSrc   =   "font/greennumber.fnt";
        break;
    case GameCharacterShape::FLOAT_NUMBER_RED:
        tmpFntSrc   =   "font/rednumber.fnt";
        break;
    case GameCharacterShape::FLOAT_NUMBER_YELLOW:
        tmpFntSrc   =   "font/yellownumber.fnt";
        break;
    default:
        break;
    }

    // 创建标签
    auto tmpText    =   Label::createWithBMFont(tmpFntSrc, numStr);
    tmpText->setPositionY(_armature->getContentSize().height / 2);
    this->addChild(tmpText, 4);
    tmpText->setScaleX(this->getScaleX());

    // 绑定浮动的动画,播放动画
    auto tmpMoveBy  =   MoveBy::create(FLOATNUMBERDIRATION, Vec2(0, FLOATNUMBERMOVEBYY));
    tmpText->runAction(Sequence::create(tmpMoveBy, CallFuncN::create(std::bind(&GameCharacterShape::onFloatNumberMoveOver, this, std::placeholders::_1)), nullptr));
}
开发者ID:tieunun,项目名称:leidota,代码行数:31,代码来源:GameCharacterShape.cpp


示例20: setPositionX

void Ball::update (float dt) {
    
    if (_body && isVisible()) {
        setPositionX(_body->GetPosition().x * PTM_RATIO);
        setPositionY(_body->GetPosition().y * PTM_RATIO);
    }
}
开发者ID:mengjiangtao,项目名称:Cocos2dx,代码行数:7,代码来源:Ball.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ setPower函数代码示例发布时间:2022-05-30
下一篇:
C++ setPosition函数代码示例发布时间: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