0 votes

Something wrong but I don't know where is, just simple some lines code, but nothing sprite show, thank for reading my post

    var scene = (PackedScene)GD.Load("res://Node2D.tscn");
    Node main_node = scene.Instance();
    texture = (Texture)GD.Load("res://asset/images/tri_32.png");       
    sprite = (Sprite)main_node.GetNode("tri8");
    sprite.Texture = texture;
    var v = new Vector2(100,100);
    sprite.Position = v;   
in Engine by (16 points)

1 Answer

0 votes

Use ResourceLoader:

texture = ResourceLoader.Load<Texture>("res://asset/images/tri_32.png");
by (150 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.