Hi.
I have some questions in C#.
1) From Sprite, cant get a texture. Edit: From a current Sprite class, Get from an external List/Array Sprites get randomly the texture, and assign it to the current Sprite class.
// I did not write all the code, because is annoying writing code in this page. Just skipped the random generation code.
public class RandomSprite : Sprite
{
[Export] public Array<Sprite> sprites = new Array<Sprite>( ); // This doesnt works
[Export] public Sprite mysprite; // This doesnt work
[Export] public Texture myTexture; // This works.
public override void _Ready()
{
Texture = sprites[0].Texture; // This does not work. // Error: Casting. Even if is not null
Texture = mysprite.Texture; // This does not work. // Error: Casting. Even if is not null
Texture = myTexture; // Why this works?
}
// code...
}
2) Change font color from a button. The only way is by code or adding RichTectLabel, Label, and change the color?
myButton.Set("custom_colors/font_color", Color.Color8(1, 1, 1, 255));
I think, there is no solution for this.
3) I need to create, inside of CollisionShape2D a Shape (RectangleShape2D), BUT, the Extents will be by code.
The thing is, I am translating one tutorial from Unity to Godot (Making a procedural level) and Creating a Room. Adding a Sprite(Tile) and random will get from a List, in this case an Array a sprite and show it.
BUT, also will get a collider (The walls or floor), BUT, the collision shape needs to fit in the sprite.
So, I dont know how to create a RectangleShape2D with its Extents in the CollisionShape2D.Shape by code.
Thank you.