https://editor.p5js.org/7vector/full/NlnUSedYI (the new game I’m working on) is currently down because I accidentally broke it, I’ll fix it when I get home (doesn’t work on mobile)

https://editor.p5js.org/7vector/sketches/7DXk4U_iW I have updated my button system, IT HAS SLIDERS NOW!!!!! Gonna make dials next

(info on how to use both sliders and buttons in comments)

2 days ago
2 1 5

comments

button info:

constructor(type ("circle" or "box", defaults to box), x,y)
type is the shape of the button's detection

input values:
x,y is the top left corner of the rectangle in box mode
x,y is the center of the circle in circle mode

active: bool
 whether the button's logic should run
hidden: bool
 whether the button should not be drawn

width: num
height: num
 used in box mode, self explanatory

radius: num
 the radius of the circle in circle mode

fill: p5js color/array
 fill color of the button, used in default rendering
stroke: p5js color/array
 stroke color of the button, used in default rendering
strokeWeight: num
 the size of the stroke in pixels

output values:

pressed: bool
 whether the button is pressed
hover: bool
 whether the mouse is over the button

timeSinceHoverChange: num 
 useful for effects

timeSincePressedChange:
 useful for effects

functions:

render()
 defines how the button looks, made to be overwritten

check()
 the functionality of the button, not recommended to be overwritten

update()
 runs the logic of the button if active, use when you want to update the button early
 should not be overwritten

draw()
 draws the button if not hidden, use when you want to draw the button early
 should not be overwritten

onUpdate() onHoverBegin() onHoverEnd() onPress() onPressBegin() onPressEnd()
 onPress runs every update when the button is held down
 event functions, do nothing by default
 intended to be overwritten

info about sliders:

new slider(
 type ("button" or "box", defaults to box),
 vertical (bool, horizontal if false),
 x, y)

Slength = number, the length of the slider, (x,y) is the bottom or leftmost point
smooth = bool, whether the slider is smooth or segmented
segments = int, how many segments the slider can go between, evenly divided

functions:
render()
what the slider looks like. comes with a default, but can be overridden

check()
the logic of the slider, can be overridden, but not recommended

! TYPO: “button” should be “circle”

also this inherits everything from button, except check and render are different by default

output values:
inherits from button

value
 if segmented is true, returns amount of segments it has passed, starting at 0
 if segmented is false, returns how many pixels it is from the origin