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


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

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


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

示例1: PixelPerfectTest

 bool PixelPerfectTest(const sf::Sprite& Object1, const sf::Sprite& Object2, sf::Uint8 AlphaLimit) {
     sf::FloatRect Intersection;
     if (Object1.getGlobalBounds().intersects(Object2.getGlobalBounds(), Intersection)) {
         sf::IntRect O1SubRect = Object1.getTextureRect();
         sf::IntRect O2SubRect = Object2.getTextureRect();
         
         sf::Uint8* mask1 = Bitmasks.GetMask(Object1.getTexture());
         sf::Uint8* mask2 = Bitmasks.GetMask(Object2.getTexture());
         
         // Loop through our pixels
         for (int i = Intersection.left; i < Intersection.left+Intersection.width; i++) {
             for (int j = Intersection.top; j < Intersection.top+Intersection.height; j++) {
                 
                 sf::Vector2f o1v = Object1.getInverseTransform().transformPoint(i, j);
                 sf::Vector2f o2v = Object2.getInverseTransform().transformPoint(i, j);
                 
                 // Make sure pixels fall within the sprite's subrect
                 if (o1v.x > 0 && o1v.y > 0 && o2v.x > 0 && o2v.y > 0 &&
                     o1v.x < O1SubRect.width && o1v.y < O1SubRect.height &&
                     o2v.x < O2SubRect.width && o2v.y < O2SubRect.height) {
                     
                     if (Bitmasks.GetPixel(mask1, Object1.getTexture(), (int)(o1v.x)+O1SubRect.left, (int)(o1v.y)+O1SubRect.top) > AlphaLimit &&
                         Bitmasks.GetPixel(mask2, Object2.getTexture(), (int)(o2v.x)+O2SubRect.left, (int)(o2v.y)+O2SubRect.top) > AlphaLimit)
                         return true;
                     
                 }
             }
         }
     }
     return false;
 }
开发者ID:Unaimend,项目名称:Pong,代码行数:31,代码来源:collision.cpp

示例2:

	KeyObject::KeyObject(float x, float y, sf::Sprite sprite, sf::Color outline, sf::String word, key_callback_t callback, bool active, bool visible) :
		GameObject(x, y, (float)sprite.getTexture()->getSize().x, (float)sprite.getTexture()->getSize().y),
		outline_(outline),
		word_(word),
		active_(active),
		focused_(false),
		visible_(visible),
		callback_(callback),
		state_(DEFAULT)
	{
		this->rect_.width = sprite.getTextureRect().width;
		this->rect_.height = sprite.getTextureRect().height;
		SetSprite(sprite);
	}
开发者ID:Ktwu,项目名称:gcs-sun-magic,代码行数:14,代码来源:key_object.cpp

示例3: ImageButton

bool ImageButton(const sf::Sprite& sprite, const sf::Vector2f& size,
    const int framePadding, const sf::Color& bgColor, const sf::Color& tintColor)
{
    const sf::Texture* texturePtr = sprite.getTexture();
    if (!texturePtr) { return false; }
    return ::imageButtonImpl(*texturePtr, static_cast<sf::FloatRect>(sprite.getTextureRect()), size, framePadding, bgColor, tintColor);
}
开发者ID:eliasdaler,项目名称:imgui-sfml,代码行数:7,代码来源:imgui-SFML.cpp

示例4: if

 inline bool operator < (const SpriteDrawClass &t) const
 {
     if(type < t.type) return true;
     else if(type > t.type) return false;
     else if(number < t.number) return true;
     else if(number > t.number) return false;
     return sprite->getTexture() < t.sprite->getTexture();
 }
开发者ID:aadarshasubedi,项目名称:mmorpg,代码行数:8,代码来源:SpriteDrawQueueClass.hpp

示例5: Image

void Image(const sf::Sprite& sprite, const sf::Vector2f& size,
    const sf::Color& tintColor, const sf::Color& borderColor)
{
    const sf::Texture* texturePtr = sprite.getTexture();
    // sprite without texture cannot be drawn
    if (!texturePtr) { return; }

    Image(*texturePtr, size, static_cast<sf::FloatRect>(sprite.getTextureRect()), tintColor, borderColor);
}
开发者ID:eliasdaler,项目名称:imgui-sfml,代码行数:9,代码来源:imgui-SFML.cpp

示例6:

const std::string	TextureManager::getSpriteName(sf::Sprite sprite)
{
	for(TextureMap::iterator it=getManager().mTextureMap.begin();it!=getManager().mTextureMap.end();it++)
	{
		sf::Texture* temp=&it->second;
		if(temp==sprite.getTexture())
		{
			return	it->first;
		}
	}
	return	"ERROR!";
}
开发者ID:Dahlqvist,项目名称:Spelprojekt1,代码行数:12,代码来源:TextureManager.cpp

示例7: create

void Animation::create(const sf::Sprite& spritesheet, const sf::IntRect spriteArea, sf::Time duration)
{
    // We get the first's frame rect
    _frameRect = spriteArea;
    // The number of sprites there is on this area
    _numberFrames = spritesheet.getTextureRect().width / spriteArea.width;

    // Setting the texture to own it
    _sprite.setTexture(*spritesheet.getTexture());
    _sprite.setTextureRect(spriteArea);

    // the duration of the animation
    _duration = duration;

    // we can say the animation is ready
    _isLoaded = true;
}
开发者ID:YoruNoHikage,项目名称:CaSFML-Defender,代码行数:17,代码来源:Animation.cpp

示例8:

 static std::vector<sf::Sprite> split4(sf::Sprite sprite)
 {
     std::vector<sf::Sprite> splits = std::vector<sf::Sprite>(0);
     const sf::Texture* texture = sprite.getTexture();
     sf::IntRect baseRect = sprite.getTextureRect();
     sf::Vector2f position = sprite.getPosition();
     splits.push_back(sf::Sprite(*texture, sf::IntRect(baseRect.left,baseRect.top,baseRect.width/2,baseRect.height/2)));
     splits[0].setPosition(position.x,position.y);
     splits[0].setColor(sprite.getColor());
     splits.push_back(sf::Sprite(*texture, sf::IntRect(baseRect.left+(baseRect.width/2), baseRect.top, baseRect.width/2, baseRect.height/2)));
     splits[1].setPosition(position.x+baseRect.width/2,position.y);
     splits[1].setColor(sprite.getColor());
     splits.push_back(sf::Sprite(*texture, sf::IntRect(baseRect.left, baseRect.top+(baseRect.height/2), baseRect.width/2 , baseRect.height/2)));
     splits[2].setPosition(position.x,position.y+baseRect.height/2);
     splits[2].setColor(sprite.getColor());
     splits.push_back(sf::Sprite(*texture, sf::IntRect(baseRect.left+(baseRect.width/2), baseRect.top+(baseRect.height/2), baseRect.width/2 , baseRect.height/2)));
     splits[3].setPosition(position.x+baseRect.width/2,position.y+baseRect.height/2);
     splits[3].setColor(sprite.getColor());
     return splits;
 }
开发者ID:ZwodahS,项目名称:LD28,代码行数:20,代码来源:f_sprites.hpp


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