Hello there. So for my game, I am trying to make so that a label appers every time the player gets hit. I thought I could use a signal like visibility changed but I didn’t do anything. Would gladly appreciate any help.
Images
Here are some images of the coding and what I am trying to do.
no not show text, but to show the sprite2d instead. Also, I would like to point out that I am not trying to with numbers, just mainly 3 specific letters.
then it’s quicker, just load the sprite according what you wanted, the value of which to show will just be the address to your resource or just an id to call which texture to show
there are many ways to make the texture ready to be used, generally using @export var, but some used @onready var to store the image, then just call it with name from match or enum, you can even put it in array so just call it with it.
it dont have to be a new scene inside a new scene just for a sprite2d, the one you will need to create and will be spawned is enough to change the sprite2d texture to what you wanted
meaning you just swap the texture of this sprite2D node according to what you wanted to show
Hey, sorry for asking this but I am still a little confused regarding this and how to apply it on gdscript, could you provide me a visual example of how that would look like?
extends Node2D
@export var sprites_texture1:Texture2D
@export var sprites_texture2:Texture2D
@export var sprites_texture3:Texture2D
@onready var sprite_2d:Sprite2D=$Sprite2D
var show_texture=null
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func set_default_value(id):
match id:
1:
show_texture=sprites_texture1
2:
show_texture=sprites_texture2
3:
show_texture=sprites_texture3
func animate_show(id):
set_default_value(id)
sprite_2d.texture=show_texture
#do the floating effect animation here
the tree:
the export in inspector dock:
to call it from other node, you first have to instantiate this scene then add child
to show what the texture, call this newly instantiated scene animate_show() method to show the floating effect after you done setting the position where it will show