itachi Posted November 15, 2022 Share Posted November 15, 2022 Hello!so i want to detect when the mouse is over a sprite and continue executing some code until the mouse exits the area...with mouseover it executes the code once and thats sadly not enough for me...with mousemove i cant execute code when the mouse just hovers in sprite...any help would be appreciated ty Quote Link to comment Share on other sites More sharing options...
Exca Posted November 17, 2022 Share Posted November 17, 2022 Use a boolean value to indicate when mouse is on & check in render. Or add the render listener when pointerover happens & remove it with pointerout. Or if you dont prefer events you can do a hittest and see if current pointer position overlaps with your object. For example let isOn = false; sprite.addEventListener("pointerover", ()=>isOn=true); sprite.addEventListener("pointerout", ()=>isOn=false); const onRender = ()=>{ if(isOn){ // do something. } } Quote Link to comment Share on other sites More sharing options...
itachi Posted November 17, 2022 Author Share Posted November 17, 2022 ty for your answer i will try it for sure! btw i was trying something like : setInterval(function(){this.emit("do things");}.bind(this),1000); do you have any idea why this failed? ty again for your help! ugameslimited 1 Quote Link to comment Share on other sites More sharing options...
ugameslimited Posted November 17, 2022 Share Posted November 17, 2022 Thanks for advice! Now it works for me too. 🏆 🏆 🏆 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.