Search code examples
c#texturessfmlsfml.net

SFML C# - Texture is not repeated


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

link: https://i.sstatic.net/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();
    }

Solution

  • Need set TextureRect for RectangleShape. For this example:

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