Control P5 Read State of Buttons
in
Contributed Library Questions
•
1 years ago
Hello,
I just worked through the spriteButton tutorial of the control P5.
I want to read out the state of the buttons. So when I have the mouse over the button / when it is clicked...
I found the function getState() but it doesn't work. Any suggestions how to read out the state of the button?
Below you'll find the code of the spriteButton example.
Thank you guys!!!!
- /**
- * ControlP5 SpriteButton
- import controlP5.*;
- import processing.opengl.*;
- ControlP5 controlP5;
- void setup() {
- size(800,400,OPENGL);
- smooth();
- frameRate(30);
- controlP5 = new ControlP5(this);
- ControllerSprite sprite = new ControllerSprite(controlP5,loadImage("buttonSprite.png"),75,75);
- sprite.setMask(loadImage("buttonSpriteMask.png"));
- sprite.enableMask();
- controlP5.Button b = controlP5.addButton("play",100,20,40,50,50);
- b.setSprite(sprite);
- b = controlP5.addButton("play2",101,120,40,50,50);
- b.setSprite(sprite);
- }
- void draw() {
- background(200);
- }
- public void play(int theValue) {
- println("playing : " + theValue);
- }
1