so what i was trying to achieve was an animation where if i am holding the sprite it resizes bigger and gets smaller when its not held, however it makes itself bigger when i simply click anywhere and i only want it to get bigger when i specifically click it, how can i do so? if necessary i will provide any extra info, thanks.
#sprite resizing when i dont click on it
1 messages · Page 1 of 1 (latest)
The manual page for Sprite2D has an example for how to test if a mouse click is on a sprite, I think you could combine that with your existing code: https://docs.godotengine.org/en/stable/classes/class_sprite2d.html#class-sprite2d-method-get-rect
Just keep in mind that the example is for a script attached to the Sprite2D node, so if you need your grow/degrow script to be in a different node you have to make sure get_rect and to_local are run on the correct object.
And btw. if you want to only count clicks on the actual object and not the entire sprite's bounding box, then I think you could use the is_pixel_opaque() function on the same manual page. Just remember to convert the mouse global coordinates to the Sprite2D's local coordinates before you call it.