Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Cannot get texture to repeat within a setTextureRect - help please :)  (Read 1817 times)

0 Members and 1 Guest are viewing this topic.

HailBee

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Here's the code I've tried:

level_Fill.setRepeated(true);
level_Fill.setSmooth(true);
level_Fill.loadFromFile("data/GeoWarsSprites.png");
background.setTexture(&level_Fill);
background.setTextureRect(sf::IntRect(205, 13, 35, 35));
background.setSize(sf::Vector2f(-1100,1100));
background.setPosition(sf::Vector2f(1100,-200));

Im *guessing* the problem is with setSize, what is the proper way to create a square set to a size much bigger than the texture and have the texture repeated? I have followed tutorials no no avail :(

edit: background is defined as a RectangleShape & level_fill as a texture.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Cannot get texture to repeat within a setTextureRect - help please :)
« Reply #1 on: September 16, 2013, 12:35:29 pm »
The shape size must be positive, and the texture rect must be bigger than the texture itself if you want it to repeat.

Note that you won't be able to repeat a subrect of the texture, it must be the whole texture.
Laurent Gomila - SFML developer

HailBee

  • Newbie
  • *
  • Posts: 25
    • View Profile
    • Email
Re: Cannot get texture to repeat within a setTextureRect - help please :)
« Reply #2 on: September 16, 2013, 02:32:20 pm »
Ahh shame about not being able to repeat a subRect but ill give it it's own image file which should solve the issue unless my negative placement gets me into trouble.

Thanks for pointing me in the right direction anyhow.