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


C++ Texture::getSize方法代码示例

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


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

示例1:

Image::Image(Menu* parent, const sf::Texture& img, float x, float y):
	Widget(parent, false)
{
	m_texture.setTexture(img);
	setPosition(x, y);
	Resize(img.getSize().x, img.getSize().y);
}
开发者ID:HoekWax,项目名称:cosmoscroll,代码行数:7,代码来源:Image.cpp

示例2: sprite

Sprite::Sprite(sf::Texture& texture, int width, int height, int frameCount, int speed, float offsetX, float offsetY, bool loop):
    sprite(texture),
    w(width),
    h(height),
    frame(0),
    numFrames(frameCount),
    timer(0),
    speed(speed),
    angle(0),
    scaleX(1.0),
    scaleY(1.0),
    offset(offsetX, offsetY),
    flipped(false),
    reverse(false),
    frozen(false),
    loop(loop),
    done(false)
{
    sprite.setOrigin(w/2, h/2);
    sprite.setTextureRect(sf::IntRect(0, 0, w, h));
    if(w > (int)(texture.getSize().x))
    {
        w = texture.getSize().x;
    }
    if( h > (int)(texture.getSize().y))
    {
        h = texture.getSize().y;
    }
    rows = texture.getSize().y / h;
    cols = texture.getSize().x / w;
    if(numFrames == -1)
    {
        numFrames = rows * cols;
    }
}
开发者ID:balbinott,项目名称:xxx,代码行数:35,代码来源:Sprite.cpp

示例3: init

void HUD::init(const sf::Texture &healthBar, const sf::Texture &healthBarBackground, const std::vector<Entity*> *players, FontManager &fontManager, int mode)
{
	scoreText.setFont(*fontManager.getResource("Config/Content/Fonts/calibri.ttf"));
	scoreText.setPosition(20,40);
	scoreText.setColor(sf::Color::Black);
	this->mode = mode;

	for(unsigned int i = 0; i < players->size(); i++)
	{
		Player *playerPtr = dynamic_cast<Player*>(players->at(i)) ;

		if(playerPtr != NULL)
		{
			this->players.push_back(playerPtr);

			healthRecs.push_back(HealthBars(sf::RectangleShape(sf::Vector2f((float)healthBar.getSize().x, (float)healthBar.getSize().y)),
				sf::RectangleShape(sf::Vector2f((float)healthBarBackground.getSize().x, (float)healthBarBackground.getSize().y))));

			healthRecs.at(i).healthBar.setTexture(&healthBar);
			healthRecs.at(i).healthBarBackground.setTexture(&healthBarBackground);

			//hardcoded
			healthRecs.at(i).healthBar.setPosition(15, 15);
			healthRecs.at(i).healthBarBackground.setPosition(10, 10);

			/*healthRecs.push_back(sf::RectangleShape(this->players->at(i)->getPlayerBars().health.getSize()));
			healthRecs.at(i).setTexture(this->players->at(i)->getPlayerBars().health.getTexture());
			healthRecs.at(i).setTextureRect(this->players->at(i)->getPlayerBars().health.getTextureRect());*/
		}
	}

	pClock.restart();
}
开发者ID:Kerswill,项目名称:Bacterium,代码行数:33,代码来源:HUD.cpp

示例4: f_addMenuItem

void menu::f_addMenuItem(sf::RenderWindow &app, sf::Texture &texture, sf::Texture &hoverTexture, std::string menuType, std::string newMenu, std::string location, sf::Vector2f position, float scaleX, float scaleY)
{
	/* Setting texture and sprite */
	m_item.setTexture(texture);
	m_item.setTextureRect(sf::IntRect(0, 0, hoverTexture.getSize().x, hoverTexture.getSize().y));
	std::cout << m_item.getTexture() << std::endl;
	m_item.setScale(scaleX, scaleY);
	f_setMenuPosition(location, position, app);
	m_menuItem.resize(m_menuItem.size() + 1);
	/* Add item */
	m_menuItem.at(m_menuItem.size() - 1).push_back(m_item);
	m_item.setTexture(hoverTexture);
	m_item.setTextureRect(sf::IntRect(0, 0, hoverTexture.getSize().x, hoverTexture.getSize().y));
	m_item.setScale(1.0f, 1.0f);
	m_item.setScale(scaleX, scaleY);
	m_menuItem[m_menuItem.size() - 1].push_back(m_item);
	std::cout << m_menuItem.size() << std::endl;
	/* Setting data into the menulist */

	m_menuList.resize(m_menuItem.size());
	m_menuList[m_menuItem.size() - 1].push_back(menuType);
	m_menuList[m_menuItem.size() - 1].push_back(location);
	m_menuList[m_menuItem.size() - 1].push_back("variable");
	m_menuList[m_menuItem.size() - 1].push_back(newMenu);
	m_menuList[m_menuItem.size() - 1].push_back("none");
}
开发者ID:Bryce910,项目名称:RadTech-Engine,代码行数:26,代码来源:menu.cpp

示例5: subrect

Slider::Slider(const sf::Font& font, const sf::Texture& texture, float length, float maxValue)
    : m_maxValue    (maxValue),
    m_length        (length),
    m_direction     (Direction::Horizontal),
    m_handleSprite  (texture),
    m_slotShape     ({ length, thickness }),
    m_text          ("", font, 36u),
    m_valueText     ("0", font, 36u),
    m_borderColour  (borderColour),
    m_activeColour  (255u, 255u, 255u, 120u)
{
    sf::IntRect subrect(0, 0, texture.getSize().x, texture.getSize().y / 2u);
    m_subRects.push_back(subrect);
    subrect.top += subrect.height;
    m_subRects.push_back(subrect);

    m_handleSprite.setTextureRect(m_subRects[State::Normal]);

    Util::Position::centreOrigin(m_handleSprite);
    m_slotShape.setOrigin(0.f, thickness / 2.f);
    m_slotShape.setFillColor(fillColour);
    m_slotShape.setOutlineColor(m_borderColour);
    m_slotShape.setOutlineThickness(thickness / 2);

    m_valueChanged.push_back(std::bind(&Slider::valueChanged, this, std::placeholders::_1));
}
开发者ID:fallahn,项目名称:xygine,代码行数:26,代码来源:UISlider.cpp

示例6:

StaticPlatform::StaticPlatform(sf::Texture& texture, float initX, float initY, float rotation)
{
	_sprite.setTexture( texture );
	
	_sprite.setOrigin( texture.getSize().x / 2.f, texture.getSize().y / 2.f);

	_sprite.setRotation( rotation );

	_bodyDef.position.Set( MathHelper::ToUnit( initX ), MathHelper::ToUnit( initY ) ); 

	_bodyDef.angle = MathHelper::DegreeToRadian( rotation );

	_bodyDef.type = b2_staticBody;

	_bodyShape.SetAsBox( 
		MathHelper::ToUnit( texture.getSize().x / 2.f ),
		MathHelper::ToUnit( texture.getSize().y / 2.f )
	);

	cout << "(" << _bodyDef.position.x << "," << _bodyDef.position.y << ")" << endl;
	
	_fixtureDef.shape = &_bodyShape;
	_fixtureDef.density = 1.f;
	_fixtureDef.friction = 0.5f;
	_fixtureDef.restitution = 0.5f;

}
开发者ID:Wajiimalik,项目名称:GamePlayground,代码行数:27,代码来源:StaticPlatform.cpp

示例7: setTexture

void Sprite::setTexture(const sf::Texture& texture, bool resetRect)
{
    // Recompute the texture area if requested, or if there was no valid texture & rect before
    if (resetRect || (!m_texture && (m_textureRect == sf::IntRect())))
        setTextureRect(sf::IntRect(0, 0, texture.getSize().x, texture.getSize().y));

    // Assign the new texture
    m_texture = &texture;
}
开发者ID:NightZpy,项目名称:RAGE,代码行数:9,代码来源:Sprite.cpp

示例8: setIcone

void Bouton::setIcone (sf::Texture& texture ){

    // on applique la texture
    m_icone.setTexture  ( &texture );

    // on reajuste la taille du textureRect à la nouvelle texture
    m_icone.setTextureRect( {0,0,texture.getSize().x, texture.getSize().y} );
    m_icone.setSize ( { texture.getSize().x, texture.getSize().y } );

}
开发者ID:c-pages,项目名称:recherche_Terrain,代码行数:10,代码来源:Bouton.cpp

示例9: setTexture

void SpriteBody::setTexture(sf::Texture& texture, int sizeW, int sizeH, int frames, int msTime )
{
    if(sizeW <= 0)
        sizeW = texture.getSize().x;
    if(sizeH <= 0)
        sizeH = texture.getSize().y;

    m_animation.setAnimation(texture, sizeW, sizeH, frames, msTime);
    m_animation.getSprite().setOrigin(sizeW/2, sizeH/2);
}
开发者ID:GustJc,项目名称:PhysicsRPG,代码行数:10,代码来源:SpriteBody.cpp

示例10: Object

Actor::Actor(sf::RenderWindow &window, b2World *world, b2FixtureDef &fixture, sf::Texture &texture, int current_index, int body_type, int shape_type)
{
	this->robot_base = new Object( window, world, fixture, texture, current_index, body_type, shape_type );

	this->jump_limit = 1.0; //the player is able to jump as often as this (in seconds)

	sf::Vector2f size( texture.getSize().x * 1.5, texture.getSize().y );
	sf::Vector2f pos( this->robot_base->getSprite()->getPosition() );

	this->healthbar = new Health( size, pos, 100, 100 );
}
开发者ID:niems,项目名称:Multiplayer-Shooter,代码行数:11,代码来源:Actor.cpp

示例11: collisionBoxList

TalkingSprite::TalkingSprite(const sf::Texture& texture, sf::Vector2f position, std::vector<sf::FloatRect>& collisionList, DNode* text)
: collisionBoxList(collisionList), whatItSays(text)
{
    setOrigin(texture.getSize().x/2, texture.getSize().y/2);
    for (auto && it : collisionBoxList) {
        it.left += position.x;
        it.top += position.y;
    }
    setTexture(texture);
    setPosition(position);

}
开发者ID:NoahKittleson,项目名称:RPG-Engine,代码行数:12,代码来源:TalkingSprite.cpp

示例12:

Player::Player(sf::Texture &texture, sf::Vector2f position)
{
	this->position = position;
	this->width = texture.getSize().x;
	this->height = texture.getSize().y;
	this->origin = sf::Vector2f(position.x + (width / 2), position.y + (height / 2));

	sprite.setTexture(texture);
	sprite.setPosition(position);

	moveSpeed = 7.0f;
}
开发者ID:Tirrax,项目名称:T3,代码行数:12,代码来源:Player.cpp

示例13: texture

Object::Object(sf::Texture &_texture
               , int _type
               , sf::Vector2f _position
               , bool _collidable
               , float _lifespan
               , float _value1
               , float _value2
               , float _value3
              )
    : texture(_texture)
    , type(_type)
    , sprite()
    , collidable(_collidable)
    , lifespan(_lifespan)
    , value1(_value1)
    , value2(_value2)
    , value3(_value3)
{
    sprite.setTexture(_texture);

    int x_width = _texture.getSize().x / 32;

    sf::Vector2u offset;

    offset.x = type % x_width;
    offset.y = type / x_width;

    sprite.setTextureRect(sf::IntRect(offset.x * 32, offset.y * 32, 32, 32));

    sprite.setPosition(_position);
    sprite.setOrigin(sprite.getLocalBounds().width / 2, sprite.getLocalBounds().height / 2);
    bounding_box = sf::IntRect(sprite.getLocalBounds().top, sprite.getLocalBounds().left, sprite.getLocalBounds().width, sprite.getLocalBounds().height);
}
开发者ID:matt7code,项目名称:DungeonOfDoom,代码行数:33,代码来源:Object.cpp

示例14: setTexture

void Ring::setTexture(const sf::Texture& texture, const bool resetRect)
{
    const bool textureWasNull{ (m_texture == nullptr) };
    m_texture = &texture;
    if (textureWasNull || resetRect)
        setTextureRect({ { 0, 0 }, sf::Vector2i(texture.getSize()) });
}
开发者ID:Stellaris-code,项目名称:Rayfun,代码行数:7,代码来源:Ring.cpp

示例15: setSpriteSheet

 void setSpriteSheet (sf::Texture* t, int frameWidth, std::vector <sf::Time> framesDur) {
     spriteSheet = t;
     width = frameWidth;
     frames = spriteSheet->getSize().x/width;
     height = spriteSheet->getSize().y;
     frameDurations = framesDur;
 }
开发者ID:StylishTriangles,项目名称:TadzikEngine,代码行数:7,代码来源:AnimatedSprite.hpp


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