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 (single view)

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
View all comments