本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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!";
}
示例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;
}
示例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;
}