I don't know why but before Godot interpreted "is_pressed()" well by itself, but now it gives it to me as an error saying that it doesn't find me declared the method.. What I want to achieve is that when I click on an object e.g. a sprite and not out the object, it should print a statement on the console, but the "is_pressed()" method by itself, Godot does not "read" it to me. In my opinion there are two possibilities: either it is a bug because as I have already written to you, it used to get it for me ; or I am doing it wrong. I hope it is the second one. Can you please help me?

is_pressed() is a method of some objects. It's not a global function. If you call it from a script extending an object that has or inherits is_pressed(), it will work.

  • Byl replied to this.

    duane I think, however, that since the script is generally a Godot resource, so it is part of the resource class. At this point the "inputevent" class is also part of the resource class, so through this reasoning I understand that I can directly access from any script the "InputEvent" class, where precisely "is_pressed" is located.. correct me if I am wrong

    InputEvent objects have an is_pressed() method, but you have to get the object from somewhere. Resource objects don't have it. Here's a tutorial on InputEvent, that might help.

    I've been trying to think of a simple way to get a mouse input from any given Sprite object, but I haven't thought of anything simpler than adding a button or getting mouse events in the main program and calculating what object they intercept.

    • Byl replied to this.

      duane So you are telling me that the touch event I want to implement cannot be done? Which for me is completely unlikely?

      Ok I solved it, I just remembered that when I was planning to create touch type objects, I was directly creating the "touchscreenbutton", in fact I created it and it worked.