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


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

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


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

示例1: afficheConstructible

void afficheConstructible  (sf::RenderWindow &App, sf::Sprite &SpriteTower ,sf::Shape &PolygonPorte,Constructible* maCons,int cote, int offSetX, int offSetY )
{
    // affichage du sprite de la construction
    int i = maCons->getPosition()->getI();
    int j = maCons->getPosition()->getJ();


    drawHexagoneIJ ( i,j, SpriteTower, cote, offSetX,  offSetY);
    //SpriteTower.SetCenter(SpriteTower.GetSize().x/2,SpriteTower.GetSize().y/2);

    sf::Vector2f positionAvant = SpriteTower.getPosition();
    SpriteTower.setPosition(positionAvant.x-SpriteTower.getTextureRect().height,positionAvant.y-SpriteTower.getTextureRect().width);
    App.draw(SpriteTower);


    // affichage de la porté
    std::set<Case *> cibles = maCons->getCaseAPorteDEffet();
    std::set<Case *>::iterator its;
    for ( its= cibles.begin() ; its != cibles.end() ; ++its )
    {
        drawHexagoneIJ ( (*its)->getI() , (*its)->getJ(), PolygonPorte, cote, offSetX,  offSetY);
         App.draw(PolygonPorte);
    }
    // les point de vue ( mon dieu c'est moche le code graphique )
    double centreX = SpriteTower.getTextureRect().width /2  ;//  SpriteTower.getTexture().getSize().x/2;
    double centreY = SpriteTower.getTextureRect().height/2 ;
    /*sf::Shape pv   = sf::Shape::Line (0,0, 0+maCons->getPV()/2 ,0,5,sf::Color::Black);
    drawHexagoneIJ (  i,j, pv, cote, offSetX,  offSetY);
    pv.Move(0-centreX,0-centreY);
    App.draw(pv);*/

}
开发者ID:GrosLapin,项目名称:TowerDefonce,代码行数:32,代码来源:Fonction_graphique.cpp

示例2: CanDraw

bool Tools::CanDraw(const sf::RenderWindow &w, const sf::Sprite & s)
{
    sf::View v = w.getView();
    sf::Vector2f size = v.getSize();
    sf::Vector2f center = v.getCenter();
    sf::IntRect screen(center.x - size.x * 0.5f - 2 * TILE_SIZE, center.y - size.y * 0.5f - 2 * TILE_SIZE, size.x + 4 * TILE_SIZE, size.y + 4 * TILE_SIZE);
    return screen.contains(static_cast<sf::Vector2i>(s.getPosition()));
}
开发者ID:Madahin,项目名称:projet_IA41,代码行数:8,代码来源:Tools.cpp

示例3: follow

void Camera::follow(sf::Sprite& sp, float d)
{
	Vector2D vd(0, d);
	vd.rotate( sp.getRotation());

	setRotation(sp.getRotation());
	setCenter( sp.getPosition() + vd);
}
开发者ID:Risist,项目名称:ggj2016-game,代码行数:8,代码来源:Camera.cpp

示例4: ClickTrigger

bool ClickTrigger(sf::Sprite &av_Sprite, sf::RenderWindow &av_Window)
{
    int mouseX = sf::Mouse::getPosition().x;
    int mouseY = sf::Mouse::getPosition().y;

    sf::Vector2i windowPosition = av_Window.getPosition();

    if(mouseX > av_Sprite.getPosition().x + windowPosition.x && mouseX < ( av_Sprite.getPosition().x + av_Sprite.getGlobalBounds().width + windowPosition.x)
        && mouseY > av_Sprite.getPosition().y + windowPosition.y + 30  && mouseY < ( av_Sprite.getPosition().y + av_Sprite.getGlobalBounds().height + windowPosition.y + 30) )
    {
        if(sf::Mouse::isButtonPressed(sf::Mouse::Left))
        {
            return true;
        }
        return false;
    }
    return false;
}
开发者ID:erisrivera19,项目名称:Examen_Casa,代码行数:18,代码来源:main.cpp

示例5: checkForMouseTrigger

bool checkForMouseTrigger(sf::Sprite &sprite, sf::RenderWindow &window)
{
	int mouseX = sf::Mouse::getPosition().x;
	int mouseY = sf::Mouse::getPosition().y;

	sf::Vector2i windowPosition = window.getPosition();

	if (mouseX > sprite.getPosition().x + windowPosition.x && mouseX < (sprite.getPosition().x + sprite.getGlobalBounds().width + windowPosition.x)
		&& mouseY > sprite.getPosition().y + windowPosition.y + 30 && mouseY < (sprite.getPosition().y + sprite.getGlobalBounds().height + windowPosition.y + 30))
	{
		if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
		{
			return true;
		}
		return false;
	}
	return false;
}
开发者ID:strap8,项目名称:SFML-Menu,代码行数:18,代码来源:main.cpp

示例6: update

	void update(sf::RenderWindow& _window) {
		_spriteG.move(_velocity.x, _velocity.y);//Personnage qui bouge


		sf::Vector2f _positionRect = sf::Vector2f(43, 50);
		_positionRect.x = _spriteG.getPosition().x;
		_positionRect.y = _spriteG.getPosition().y;

		_rect.setPosition(_positionRect.x, _positionRect.y);
	}
开发者ID:W0Z4,项目名称:ProjetMario,代码行数:10,代码来源:Goomba.hpp

示例7: isInViewingDistance

bool Entity::isInViewingDistance(sf::Sprite opponent) {


	sf::Vector2f position = opponent.getPosition();
	sf::FloatRect bounds = opponent.getLocalBounds();
	const sf::Rect<float> opponents_rect(position.x, position.y, 32, 32);
	return false;
	//return perimeter.intersects(opponents_rect);

}
开发者ID:anthonybjturner,项目名称:YasuosQuests,代码行数:10,代码来源:Entity.cpp

示例8: moveLeft

void Camara::moveLeft(sf::Sprite& personaje){
    
    if(desplazamientoCamara!=0){
        if(personaje.getPosition().x<= camara->getSize().x*0.4 + desplazamientoCamara && camara->getCenter().x!=posicionOrigenCamara){
            camara->move(-kVel,0);
            desplazamientoCamara=desplazamientoCamara-kVel;   
        }
    }
    
}
开发者ID:ismap1993,项目名称:BitCrushers,代码行数:10,代码来源:Camara.cpp

示例9: isCollMario

	void isCollMario(Mario& _mario) {
		if (getBoundingBox().intersects(_mario.getBoundingBox())) {
			cout << "col enemie" << endl;
			if ((getBoundingBoxTop()< _mario.getBoundingBoxTop()) && (mort == false)) {
				mort = true;
			}
			else if ((_spriteG.getPosition().y > _mario.getBoundingBoxTop()) && (mort == false)) {
				cout << "Mario Rip" << endl;
			}
			else {

				if ((_spriteG.getPosition().x < _mario.getBoundingBoxLeft() - 12) && (mort == false)) {//Left

					cout << "Mario Rip" << endl;
				}
				else if ((_spriteG.getPosition().x > _mario.getBoundingBoxLeft() + 23) && (mort == false))//right
					cout << "Mario RIP" << endl;
			}
		}
	}
开发者ID:W0Z4,项目名称:ProjetMario,代码行数:20,代码来源:Goomba.hpp

示例10: LowAmmo

void cursor::LowAmmo(int current, int maximum)
{
    lowAmmoSprite.setPosition(sprite.getPosition());
    lowAmmoSprite.setRotation(sprite.getRotation());

    double ammoLimit = 0.3 * maximum;
    double ammoPseudoPercentage = static_cast <float> (current) / ammoLimit;
    ammoPseudoPercentage *= 255;

    lowAmmoSprite.setColor(sf::Color(255, 255, 255, 255 - ammoPseudoPercentage));
}
开发者ID:KoczurekK,项目名称:Battle-of-Hrubieszow-old,代码行数:11,代码来源:cursor.hpp

示例11: HighAmmo

void cursor::HighAmmo(int current, int maximum)
{
    highAmmoSprite.setPosition(sprite.getPosition());
    highAmmoSprite.setRotation(sprite.getRotation());

    double pseudoAmmo = current - (0.7 * maximum);
    double pseudoAmmoMax = maximum - (0.7 * maximum);

    double ammoPseudoPercentage = static_cast <float> (pseudoAmmo) / pseudoAmmoMax;
    ammoPseudoPercentage *= 255;

    highAmmoSprite.setColor(sf::Color(255, 255, 255, ammoPseudoPercentage));
}
开发者ID:KoczurekK,项目名称:Battle-of-Hrubieszow-old,代码行数:13,代码来源:cursor.hpp

示例12: colidiu

void Bola::colidiu(sf::Sprite lightsaber){//Testar se realmente funcionou a colisao com sabre menor/maior
    if(this->getGlobalBounds().intersects((lightsaber.getGlobalBounds())))
    {
        laser2.play();
        if(this->getPosition().y<lightsaber.getPosition().y){
            speed.y *=(-1);

            float a=this->getPosition().x-(lightsaber.getPosition().x-(50*lightsaber.getScale().x));
            if(a<-10){//Lado esquerdo
                a*=-1;
                if(speed.x>0)
                    speed.x-=a*0.1;
                else
                    speed.x-=a*0.1;
            }else if(a>10){//Lado direito
                if(speed.x>0)
                    speed.x+=a*0.1;
                else
                    speed.x+=a*0.1;
            }
        }else
            speed.x*=-1;
    }
}
开发者ID:lautter,项目名称:ProjetoFinal,代码行数:24,代码来源:Bola.cpp

示例13: handle

        void handle () {
            rotate();
            float percentageHealth = float((Health/MaxHealth) * 100);
            HealthBarGreen.setSize(sf::Vector2f(percentageHealth * (HealthBarSize / percentageHealth), 5));

            NameOutline.setPosition(Sprite.getPosition().x + 1.5, Sprite.getPosition().y + nameSpacing + 4);
            PlayerName.setPosition(Sprite.getPosition().x, Sprite.getPosition().y + nameSpacing);
            HealthBarRed.setPosition(Sprite.getPosition().x - (CharacterWidth/2) - 5, Sprite.getPosition().y + healthBarSpacing);
            HealthBarGreen.setPosition(Sprite.getPosition().x - (CharacterWidth/2) - 5, Sprite.getPosition().y + healthBarSpacing);
            }
开发者ID:IncredibleSulk,项目名称:Neverdoom,代码行数:10,代码来源:players.hpp

示例14: update

void Model::update( const sf::Sprite& parent)
{
	float alfa=((parent.getRotation() + rotAround)* M_PI) /180.f;
	sf::Vector2f v,p(pos.x * parent.getScale().x, pos.y * parent.getScale().y);

	v.x = p.x * cos(alfa) - p.y * sin(alfa);
	v.y = p.x * sin(alfa) + p.y * cos(alfa);

	setRotation(parent.getRotation() + rot);
	setPosition(parent.getPosition() + v + posNoRot);

	sf::Sprite::setScale(	ModelDef::scale.x * parent.getScale().x, 
							ModelDef::scale.y * parent.getScale().y	);

	//setColor( sf::Color( clR, clG, clB, clA ) );
}
开发者ID:Risist,项目名称:ggj2016-game,代码行数:16,代码来源:Model.cpp

示例15: getOBB

Collision::OBB Collision::getOBB(const sf::Sprite& object){
	//Gets the oriented bounding box of object, which is the local bounds of the object rotated
	sf::FloatRect box(object.getLocalBounds());
	maths::Vector2 topleft, botright, topright, botleft;

	float rot = object.getRotation();
	maths::Vector2 origin = object.getOrigin();
	maths::Vector2 position = object.getPosition();
	
	//Get rotated coordinates of vertices
	topleft = position + maths::Vector2(box.left, box.top).rotate(rot, origin);
	botright = position + maths::Vector2(box.left + box.width, box.top + box.height).rotate(rot, origin);
	topright = position + maths::Vector2(box.left + box.width, box.top).rotate(rot, origin);
	botleft = position + maths::Vector2(box.left, box.top + box.height).rotate(rot, origin);


	return OBB(topleft, botleft, topright, botright);
}
开发者ID:pighead10,项目名称:sfpy-gmk,代码行数:18,代码来源:Collision.cpp


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