Hi! I'm trying to make a short clicking based game where you click on 'sprites' i guess and then they move to a point on the screen (it's heavily text based). I'm planning to use the animationplay feature to make this happen but my problem has been that the sprites all move no matter where i click on the screen, instead of the specific one i've clicked. I tried to get around this by adding a texturebutton (didn't work, removed it) and now am using the Control feature, but i've run into a problem with the mouse.

Here is my code: onready var heartorgantest = $OrganTestRemovalForGame/HeartOrganTest onready var heartmove = $OrganTestRemovalForGame/HeartOrganTest/heartmove onready var heartcontrol = $OrganTestRemovalForGame/HeartOrganTest/heartcontrol

if mouse_entered("heartcontrol"):
	if Input.is_action_just_pressed("right_click"):
		heartmove.play("heartanim")
		print ("clicked")

My problem has been with the "mouse_entered" line, it says that it is not declared in current class. I know some of python but am new to gdscript so i'm unsure of what this means or how to fix it, any help would be appreciated thanks

mouse_entered is a signal. You don't call that like a normal function. Take a look at the using signals section in the documentation. You connect the signal to a function/method, which then activates when the mouse enters the area.

In your case, you might connect the signal to a method that sets a variable to the name of the object the mouse is over. Then you could write an _input() method that watches for a mouse click and checks the variable to see what just got clicked.

7 months later