本文整理汇总了C++中sf::Texture::setRepeated方法的典型用法代码示例。如果您正苦于以下问题:C++ Texture::setRepeated方法的具体用法?C++ Texture::setRepeated怎么用?C++ Texture::setRepeated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Texture
的用法示例。
在下文中一共展示了Texture::setRepeated方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromLv
void Level::loadFromLv(b2World& World, std::string levelPath)
{
std::cout << levelPath << std::endl;
std::string line;
std::ifstream myfile (levelPath);
if (myfile.is_open())
{
//current level object init
while ( getline (myfile,line) )
{
std::regex groundRegex("(ground),(.*),(.*),(.*),(.*),(.*)");
std::smatch groundObject;
if (std::regex_match(line,groundObject,groundRegex))
{
std::cout << groundObject[5].str() << std::endl;
CreateGround(World, std::stof(groundObject[2].str()), stof(groundObject[3].str()), stof(groundObject[4].str()), stof(groundObject[5].str()));
// CreateGround(World, 5, 5, 5, stof(groundObject[5].str()));
GroundTexture.loadFromFile(groundObject[6]);
GroundTexture.setRepeated(true);
}
}
std::cout << levelPath << std::endl;
myfile.close();
}
else std::cout << "Unable to open file" << std::endl;
}
示例2: IntRect
TimedSpikes::TimedSpikes(sf::Texture& texture, float initX, float initY, int repeatTimes,float restitution)
{
//StaticPlatform(texture, initX, initY, repeatTimes);
_sprite.setTexture( texture );
//texture will be repeated 'repeatTimes' times along X-direction
_sprite.setTextureRect( IntRect( 0, 0, repeatTimes * texture.getSize().x, texture.getSize().y ) ) ;
texture.setRepeated( true );
_sprite.setOrigin( repeatTimes * texture.getSize().x / 2.f, texture.getSize().y / 2.f);
_bodyDef.position.Set( MathHelper::ToUnit( initX ), MathHelper::ToUnit( initY ) );
//_bodyDef.angle = MathHelper::DegreeToRadian( rotation );
_bodyDef.type = b2_staticBody;
_bodyShape.SetAsBox(
MathHelper::ToUnit( repeatTimes * 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 = restitution;
cycleClock.restart();
}
示例3: create
void AnimatedSphere::create(sf::Texture& tex, float radius, const sf::Time& time)
{
circle.setTexture(&tex);
tex.setRepeated(true);
if(radius < 0)
throw std::logic_error{ "Circle's radius cannot be negative! Radius = " + std::to_string(radius) };
float diam = 2 * radius;
texRect = { 0, 0, (int)diam, (int)diam };
circle.setRadius(radius);
passed = sf::Time::Zero;
animTime = time;
texRect = { 0, 0, 2 * (int)radius, 2 * (int)radius };
circle.setTextureRect(texRect);
}