简体   繁体   中英

SFML C# - Texture is not repeated

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();
    }

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

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

Need set TextureRect for RectangleShape. For this example:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM