-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing rectMode #6
Comments
Click detection is done [as of 2020/08/04] on line 127-128 if (mouseX >= this.x && mouseY >= this.y
&& mouseX < this.x + this.width && mouseY < this.y + this.height) { This section is checking for if the mouse is below and to the right of the top left corner if (mouseX >= this.x && mouseY >= this.y And this section is making sure its above and to the left of the bottom right corner && mouseX < this.x + this.width && mouseY < this.y + this.height) { If you want to, you could submit a pull request to add "this.rectMode" and add an if/else for the click detection. Example: // Corner is the default rectMode for p5.js
if (this.rectMode == CORNER) {
if (mouseX >= this.x && mouseY >= this.y
&& mouseX < this.x + this.width && mouseY < this.y + this.height) {
// Insert current click things
}
} else if (this.rectMode == CENTER) {
if (mouseX >= this.x - this.width/2 && mouseY >= this.y - this.height/2
&& mouseX < this.x + this.width/2 && mouseY < this.y + this.height/2) {
// Insert current click things
}
} remember to add a |
Hi there! I've left this library quite unattended for some time now, sorry. What @Samathingamajig says is right (thank you so much for taking the time to answer!) and I'll try to add this as a feature as soon as possible. Over the next few days I'll set some time aside to improve this library based on what people have been requesting ❤️ |
Hi. Is this still an issue? If yes then I would like to work on it and submit a pull request. |
It's still an issue, I haven't had the time to work on this lib for some time now. If you want to do some housekeeping, you are more than welcome! |
Hey sorry about late reply. I did not know GitHub had a notifications panel, and I thought you had never replied. (I am pretty new to using GitHub for collaborating, so far mostly used it to keep a backup of my personal projects only). I will be submitting a pull request shortly. |
In my code I'm using rectMode(CENTER) to make playing the buttons on the screen a bit easier. This works for displaying the Clickable however the area for the onPress function still remains where it would be if I hadn't changed the rectMode. I'm new to coding so there may be a simple fix to this that I'm missing
The text was updated successfully, but these errors were encountered: