Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | YumeSharkMekzGemz |
Im generally new to GDScript, so I dont really know all the code. Even in the 2D forums, I couldnt find anything that works like, if the cursor is touching the sprite then the if statement starts rolling, simple. I tried using the _on_mouse_entered and _on_mouse_exit, but it didnt work. I dont know if those statements are used for something else, or Im just not doing it right. Im trying to make it so a animation plays when the mouse starts hovring over the sprite, then a different animation while its hovering. The same for when not. When it leaves the cursor, animation, the whenever its not touching the cursor, a different one. I tried this at some point
func _on_mouse_entered:
isHover = true
#do stuff
while isHover == true:
#do stuff
func _on_mouse_exit:
isHover = false
#do other stuff
while isHover == false:
#do other stuff
If you put a while loop inside the _on_mouse_entered
function, it will lock up the game since it won’t register anything until after the loop. Since the entire game is like a while loop, you should put a check in a process function for isHover instead, if what you want needs to be repeated each frame. It really depends on what specifically you want to do when the mouse is hovering over the Node.
exuin | 2021-06-07 12:46
Since the entire game is like a while loop, you should put a check in a procces function for isHover instead
ummm… what do you mean by check. I looked it up, and checked the forums for anything related to that, but couldnt really find anything. Is that a built in function, like,
check(isHover == true):
#output
like, how does that work. I dont really understand GDScript. Im used to Java, Javascript, and some #C
YumeSharkMekzGemz | 2021-06-07 18:08
It’s not a function, what I meant was to put an if statement inside a process function.
exuin | 2021-06-07 18:43