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


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

本文整理汇总了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;
}
开发者ID:rossgb,项目名称:Zekespuzzle,代码行数:33,代码来源:level.cpp

示例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();

}
开发者ID:Inshal240,项目名称:Side-Scroller-Game,代码行数:34,代码来源:TimedSpikes.cpp

示例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);
}
开发者ID:GuildMasterInfinite,项目名称:SpaceExplorer,代码行数:19,代码来源:AnimatedSphere.cpp


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