![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | freaki2010 |
I want an action to be executed when a sprite is clicked (with touch). I have tried to solve this with the following post (https://forum.godotengine.org/3825/check-if-sprite-self-is-clicked) but unfortunately it does not work as expected… It does not react to anything anymore. With my previous code I was able to capture at least a touch input on the whole screen.
Here is my code where the touch input on the hole screen works and how I built the scene.
extends Area2D
func _ready():
pass # Replace with function body.
func _input(event: InputEvent) -> void:
if event is InputEventScreenTouch and event.is_pressed():
print("clicked")
Scene Build pictures: Godot Game post - Album on Imgur
This scene
I want to instantiate the scene with the sprite into the main scene, where by pressing the sprite values should be changed.
Code of the main scene:
extends Node
onready var touches_label : Label = $Container/VBoxContainer/Touches
var click_count := 0.0
func _ready() -> void:
update_touches_label()
func update_touches_label() -> void:
touches_label.text = str(click_count)