本文整理汇总了C++中sf::Sprite::getLocalBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite::getLocalBounds方法的具体用法?C++ Sprite::getLocalBounds怎么用?C++ Sprite::getLocalBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Sprite
的用法示例。
在下文中一共展示了Sprite::getLocalBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Arvid::Arvid(sf::Vector2f &position) /*:
mIdleLeftAnimation ("", 0, 0),
mIdleRightAnimation ("", 0, 0),
mRunLeftAnimation ("", 0, 0),
mRunRightAnimation ("", 0, 0),
mJumpAnimation ("", 0, 0)*/
{
mEntityKind = ARVID;
setPosition(position);
TEXTURE.loadFromFile("GUBBJEVEL.png");
SPRITE.setTexture(TEXTURE);
mHitBox.width = SPRITE.getLocalBounds().width;
mHitBox.height = SPRITE.getLocalBounds().height;
SPRITE.setPosition(position);
}
示例2: SpriteNode
SpriteNode(const sf::Texture& t,
sf::Vector2f pos)
: mSprite(t)
{
sf::FloatRect bounds = mSprite.getLocalBounds();
mSprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);
mSprite.setPosition(pos);
};
示例3: init
void WindowCreateThing::init(sf::RenderWindow &window) {
rectTitle.setSize(sf::Vector2f(window.getSize().x*0.45, window.getSize().y*0.07));
rectTitle.setPosition(sf::Vector2f(window.getSize().x/2-(rectTitle.getSize().x/2), window.getSize().x/4-(rectTitle.getSize().y/2)));
rectTitle.setFillColor(sf::Color(158, 158, 158));
rectTitle.setOutlineColor(sf::Color::Black);
rectTitle.setOutlineThickness(1.f);
rectMain.setSize(sf::Vector2f(window.getSize().x*0.45,window.getSize().y*0.45));
rectMain.setPosition(sf::Vector2f(rectTitle.getPosition().x, rectTitle.getPosition().y+rectTitle.getSize().y));
rectMain.setFillColor(sf::Color::White);
rectMain.setOutlineColor(sf::Color::Black);
rectMain.setOutlineThickness(1.f);
load();
starting_position = sf::Mouse::getPosition(window);
textTitle.setFont(font);
textTitle.setString("CreateThings.txt");
textTitle.setCharacterSize(24);
textTitle.setColor(sf::Color::White);
textTitle.setPosition(sf::Vector2f(rectTitle.getPosition().x+rectTitle.getSize().x*0.3, rectTitle.getPosition().y+rectTitle.getSize().y*0.1));
//textTitle.setPosition(sf::Vector2f(400,10));
textClose.setFont(font);
textClose.setString("X");
textClose.setStyle(sf::Text::Bold);
textClose.setCharacterSize(35);
textClose.setColor(sf::Color::White);
textClose.setPosition(sf::Vector2f(rectTitle.getPosition().x+rectTitle.getSize().x-30, rectTitle.getPosition().y+rectTitle.getSize().y*0.05));
///// FOLDER ICONE
textureFolder.setSmooth(true);
spriteFodler.setTexture(textureFolder);
sf::Vector2f targetSize(25.0f, 25.0f);
spriteFodler.setScale(
targetSize.x / spriteFodler.getLocalBounds().width,
targetSize.y / spriteFodler.getLocalBounds().height);
spriteFodler.setPosition(sf::Vector2f(textTitle.getPosition().x-targetSize.x, textTitle.getPosition().y));
///// CLOSE ICONE
/*textureClose.setSmooth(true);
spriteClose.setTexture(textureClose);
sf::Vector2f targetSize2(window.getSize().y*0.07, window.getSize().y*0.07);
spriteClose.setScale(
targetSize2.x / spriteClose.getLocalBounds().width,
targetSize2.y / spriteClose.getLocalBounds().height);
spriteClose.setPosition(rectTitle.getPosition().x+rectTitle.getSize().x-targetSize2.x, rectTitle.getPosition().y);*/
}
示例4: Scenery
Scenery(LevelBlock* host
, const sf::Texture& texture)
: mHostBlock(host)
, mSprite(texture)
{
sf::FloatRect bounds = mSprite.getLocalBounds();
mSprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);
mSprite.move(20.f, 20.f);
};
示例5: 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);
}
示例6: set_origin
void set_origin()
{
const float mult{0.27f};
assert(mult > 0.0f);
const sf::FloatRect m_image_bounds{m_sprite.getLocalBounds()};
m_sprite.setOrigin(0.5f*m_image_bounds.width, 0.5f*m_image_bounds.height);
m_radius = mult*(m_image_bounds.width + m_image_bounds.height);
}
示例7: 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);
}
示例8: value
EnergyMeter::EnergyMeter(const sf::Sprite &overlay, const float &maximumValue)
: value(maximumValue)
, maximumValue(maximumValue)
, orientation(-1)
, overlay(overlay)
, primaryColor(DEFAULT_PRIMARY_COLOR)
, secondaryColor(DEFAULT_SECONDARY_COLOR)
, fillColor(DEFAULT_FILL_COLOR)
{
setVisible(true);
foreground.setSize(
sf::Vector2f(
overlay.getLocalBounds().width,
overlay.getLocalBounds().height
)
);
primaryBackground.setSize(foreground.getSize());
secondaryBackground.setSize(
sf::Vector2f(
2.0f,
foreground.getSize().y
)
);
setFillColor(fillColor);
setPrimaryColor(primaryColor);
setSecondaryColor(secondaryColor);
setPosition(
sf::Vector2i(
static_cast<int>(overlay.getPosition().x),
static_cast<int>(overlay.getPosition().y)
)
);
setOrientation(VERTICAL_ORIENTATION);
updateFill();
}
示例9: Entity
Entity(sf::Texture& sTexture, EntityType type, Collidable::Type colType, sf::SoundBuffer& soundBuf1, sf::SoundBuffer& soundBuf2)
: Collidable(colType)
, mSprite(sTexture)
, mDeathSound(soundBuf1)
, mLaserSound(soundBuf2)
, mType(type)
, mCollected(0)
, mFireProjectile(false)
, mFireCountdown(sf::Time::Zero)
{
sf::FloatRect bounds = mSprite.getLocalBounds();
mSprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);
switch(type)
{
case EntityType::Player: mHitPoints = PlayerHitPoints; break;
case EntityType::Enemy: mHitPoints = EnemyHitPoints; break;
default: break;
}
mLaserSound.setVolume(75.f);
mDeathSound.setVolume(75.f);
};
示例10: OrientedBox
void TEALShow::OrientedBox( sf::Sprite &s, sf::Color col)
{
AddTransformedRectanglePoints( s.getLocalBounds(), s.getTransform(), col );
}
示例11: centerOrigin
void centerOrigin(sf::Sprite& sprite)
{
sf::FloatRect bounds = sprite.getLocalBounds();
sprite.setOrigin(bounds.left + bounds.width / 2.f, bounds.top + bounds.height / 2.f);
}
示例12: isSpriteClicked
bool MapEditor::isSpriteClicked(sf::Sprite& spr, sf::Vector2f *mousePos){
return mousePos->x > spr.getPosition().x
&& mousePos->x < spr.getPosition().x + spr.getLocalBounds().width
&& mousePos->y > spr.getPosition().y
&& mousePos->y < spr.getPosition().y + spr.getLocalBounds().height;
}
示例13: CenterSprite
void CenterSprite(sf::Sprite& sprite, const sf::RenderTarget& target)
{
sf::FloatRect sprite_bounds = sprite.getLocalBounds();
sprite.setOrigin(sprite_bounds.left + (sprite_bounds.width/2.0f), sprite_bounds.top + (sprite_bounds.height/2.0f));
sprite.setPosition(sf::Vector2f(target.getSize() / (unsigned)2));
}
示例14: CenterSpriteVert
void CenterSpriteVert(sf::Sprite& sprite, const sf::RenderTarget& target)
{
sf::FloatRect sprite_bounds = sprite.getLocalBounds();
sprite.setOrigin(0, sprite_bounds.top + (sprite_bounds.height/2.f));
sprite.setPosition(sprite.getPosition().x, target.getSize().y/2.f);
}
示例15: CenterSpriteHor
void CenterSpriteHor(sf::Sprite& sprite, const sf::RenderTarget& target)
{
sf::FloatRect sprite_bounds = sprite.getLocalBounds();
sprite.setOrigin(sprite_bounds.left + (sprite_bounds.width/2.f), 0);
sprite.setPosition(target.getSize().x/2.f, sprite.getPosition().y);
}