0 votes

I have a scene with an Area2D at the root, and have created a signal for when the mouse enters the sprite. When I run the scene on its own, when I mouse over the Area2D, I'm able to generate a message in the log just fine:

extends Area2D

signal mouse_touch

func _on_Letter_mouse_touch():
    print("Mouse touch")

func _on_Letter_mouse_entered():

BUT-- from my 'main' scene, I'm trying to connect the same signal to an instance of a scene, but the mouseover does work from the main scene, something like this:

var c = Letter.instance()
c.connect("mouse_touch", self, "_on_Letter_mouse_touch")

Is this not the proper way to handle this?


in Engine by (12 points)

Would it be possible to post more stuff, like your code and node layout?


extends Node2D

export (PackedScene) var Letter

export (int) var Playtime

var level
var score
var time_left
var screensize
var playing = false
var letter_array = []
var letter_cell
var letters = []
var word_list = ['bird', 'dog', 'cat', 'apple', 'food', 'house', 'mommy', 'daddy', 'milk']

func _ready():
    screensize = get_viewport().get_visible_rect().size

func _process(delta):
    if playing and $LetterContainer.get_child_count() == 0:
        level += 1
        time_left += 5
        spawn_letters(word_list[randi() % 9])

func new_game():
    playing = true
    level = 1
    score = 0
    time_left = Playtime
    spawn_letters(word_list[randi() % 8])

func spawn_letters(word):
    for letter in word:
        letter_cell = Vector2(randi() % 9, randi() % 10)
        var result = letter_array.find(letter_cell)
        if result != -1:
    var i = 0
    for letter in letter_array:
        var l: Area2D = Letter.instance()
        l.get_child(0).text = word.substr(i, 1)
        i = i + 1
        l.position = Vector2((letter[0] * 48) + 16, (letter[1] * 48) + 64)
        l.connect("_on_Letter_mouse_entered", self, "_on_Letter_mouse_touch")

func _on_GameTimer_timeout():
    time_left -= 1
    if time_left <= 0:

func _on_Player_pickup(type):
    match type:
            score += 1

func game_over():
    playing = false
    for letter in $LetterContainer.get_children():

func _on_HUD_start_game():

func _on_Letter_mouse_touch():


extends Area2D

func _on_Letter_mouse_entered():

func _on_Letter_mouse_touch():

Letter scene signal:


l.connect("_on_Letter_mouse_entered", self, "_on_Letter_mouse_touch")

So _on_Letter_mouse_entered is not the signal, but is instead the name of the function. You want to connect the mouse_entered signal.

Ah, my mistake....however, changing that to "mouse_entered" still has no effect.


I recreated your scene minimally and I wasn't able to get your error. I'm sorry, I think there might be something else wrong.

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.