简体   繁体   English

SFML C# - 纹理不重复

[英]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链接: 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.需要为 RectangleShape 设置 TextureRect。 For this example:对于这个例子:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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