ct.mouse.hovers is triggered permanently instead of per-frame
See original GitHub issueDescribe the bug I have multiple copies and am trying to perform an action only for the specific copy the user clicks on. I do this check by using the following:
if (ct.actions.MYACTION.pressed && ct.mouse.hovers(this)) {
// ...etc.
}
However, it looks like ct.mouse.hovers(this)
returns true if your mouse has hovered over this copy at any point during the lifetime of the game.
To Reproduce Steps to reproduce the behavior:
- Create an action and set it to left mouse click.
- Create a Type using any texture you want.
- Place multiple copies of the Type into a Room.
- Paste the snippets of code shown below.
- Start the game in debug. Make sure you don’t hover over any copies to start.
- Pick any copy and click on it. Observe the console correctly printing position and integer.
- Then hover over another copy. Observe how not only did your current copy you clicked/hovered on change, but also the one you previously clicked, but are not hovering over anymore.
On Create:
this.current = 0;
On Step:
if (ct.actions.YOUR_ACTION.pressed && ct.mouse.hovers(this)){
this.current++;
console.log(this.position.x + "," + this.position.y + ": " + "this.currentState);
}
this.move();
Expected behavior
I would have expected ct.mouse.hovers(this)
to return true only if the mouse pointer is currently hovering over the current copy, false otherwise.
Screenshots (recommended)
After clicking first square (X marks which square I clicked):
After clicking second square:
After clicking 3rd square:
Versions:
- OS: macOS Catalina 10.15.7
- ct.js version: 1.5.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Mouseover and mouseout trigger multiple times - Stack Overflow
You can avoid this issue by using mouseenter instead of mouseover , and mouseleave instead of mouseout . The reason is simple: mouseenter...
Read more >the of and to a in for is on s that by this with i you it not
... silver corporation wish inside solution mature role rather weeks addition ... lighting senate forces funny ct brother gene turned portable tried hawaii ......
Read more >www.allitebooks.com - Pepa
mechanism is triggered to play a sound. in the same way, you can detect when a user hovers the mouse over a link...
Read more >walmart air freshners
8-Pack Bamboo Charcoal Air Purifier Bag Natural Air Freshener Activated Carbon ... 19/ea Air Wick Plug in Scented Oil Refill, 5 ct, Lavender...
Read more >Will Jenelle Evans Return to Teen Mom 2 Fans Think So her
... made several statements about permanently cutting ties with her. ... Evans (@j_evans1219) Why did Jenelle get fired from ' Teen Mom 2' ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I downloaded it and checked. It’s because your collision mask is 512x512 but your sprites are 128x128. So they are overlapping each other causing you to click multiple at a time 😃
🤦 Thank you for finding that. I don’t know when that was changed or how it got that way but thank you! I’ll close the issue.