SFML C# - Texture is not repeated

121 Views Asked by At

In this example, the texture is not repeated. What could I have missed?

link: https://i.stack.imgur.com/lsEub.png

    void Game_Draw()
    {
        window.Clear(Color.Black);
        window.DispatchEvents();

        RectangleShape r = new RectangleShape()
        {
            Position = new Vector2f(20, 20),
            Size = new Vector2f(100, 20)
        };

        Texture t = new Texture("Textures/T_Angle.png")
        {
            Repeated = true
        };

        r.Texture = t;

        Console.WriteLine(r.Texture.Size);

        window.Draw(r);

        window.Display();
    }
2

There are 2 best solutions below

0
 RAY On BEST ANSWER

Need set TextureRect for RectangleShape. For this example:

r.TextureRect = new IntRect(0, 0, 100, 20);
0
Jukoz On

For your texture, try this instead and Debug line per line if needed.

Texture texture;
texture.loadFromFile("Textures\\T_Angle.png");
texture.setRepeated(true);