0 votes

extends Node2D#Spawner

const enemy = preload("res://enemy.tscn")

func onTimer_timeout():

var posX = rand_range(700, 1250)   
var posY = 0
var fall = enemy.instance()
fall.position = Vector2(posX, posY) 
$Timer.wait_time = max(.01, $Timer.wait_time - 0.01) 

extends Node#global.gd

var letters = ["a", "b", "c"]
var sel = ""

var temp = ""
var A = "a"
var B = "b"
var C = "c"

signal tile_destroyed

func _process(delta):

sel = letters[rand_range(0, len(letters))]

func letterDestroyed():


extends Area2D

var wordA = ""
var motion = Vector2()
onready var sprite = get_node("Sprite")#Get's the Sprite of the node

var A = preload("res://A.png")#Image A
var B = preload("res://B.png")#Image B
var C = preload("res://C.png")#Image C

func ready():
if global.sel == global.A:
print(global.sel + "-")
print(global.A + "-")
texture(A)#Changes the image to A if global.sel = A

if global.sel == global.B: 
    print(global.sel + "+")
    print(global.B + "+")
    sprite.set_texture(B)#Changes the image to B if global.sel = B

if global.sel == global.C:
    print(global.sel + "'")
    print(global.C + "'")
    sprite.set_texture(C)#Changes the image to C if global.sel = C

func physicsprocess(delta):
motion.y = 170 * delta

func onNode2Dinputevent(viewport, event, shapeidx):
if event.is
global.temp = global.sel
print(global.temp + " if pressed")

    if global.temp == global.A:
        global.temp = global.A

    elif global.temp == global.B:
            global.temp = global.B

    elif global.temp == global.C:
            global.temp = global.C

    global.letterDestroyed()#Global signal to display the letter if Area2D is destroyed

extends RichTextLabel

const sp = preload("res://enemy.tscn")

func ready():
destroyed", self, "updatetext")

func updatetext(): #add letters to the screen(RichTextLabel)
if global.temp == global.A:

elif global.temp == global.B:

elif global.temp== global.C:
in Engine by (12 points)

Can't see what's the issue here! Your code runs fine: if I click on an enemy (spawning at a random x-position at the top border of the screen and moving downwards with constant velocity), it's freed and the letter currently saved in global.temp is added to the RichTextLabel. Which seems to be exactly what you are asking for?

Also please format your code properly. Every line in a code block has to be indented, use the Preview below the editor window to make sure everything looks alright. You can still edit your post by clicking on the three dots at the lower right of your question.

Thanks and my bad this is the first time I'm posting and I didn't explain it well, my problem is when I clicked the falling letters for example A, sometimes a "C" would display. I random generate the letters in global.gd in the func _process(delta): and even though I save the in global.temp I get that problem.

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.