Hi everyone, I created a button with lp5 control but I can’t get it to work. I want it to function as a start button and click on it to start the code I already create. Thank you!
This is what i have in the botton code:
import processing.video.*;
import controlP5.*;
Movie video;
ControlP5 cp5;
void setup() {
size(600,400);
video = new Movie(this, "video1.mov");
video.loop();
cp5 = new ControlP5(this);
cp5.addButton("boton1")
.setPosition(220,200)
.setImage(loadImage("boton1.png"));
//.updateSize();
}
void movieEvent(Movie video) {
video.read();
}
void draw() {
image(video,0,0);
}
public void controlEvent(ControlEvent theEvent) {
println(theEvent.getController().getName());
}
// function buttonA will receive changes from
// controller with name buttonA
public void buttonA(int theValue) {
println("a button event from button1: "+theValue);
}
and this is the beginning of my other code
JSONArray values;
int imgCount = 189;
int imgCount2 = 189;
int imgActual2;
PImage [] imgs = new PImage [imgCount];
PImage [] img01 = new PImage [imgCount2];
int imgActual;
PImage bg;
PImage fondo;
PImage user;
PImage cuadro;
PImage edrtext;
PFont font1;
PFont font2;
void setup () {
size(1404,872);
frameRate(60);
fondo = loadImage("fondoedr1.png");
bg = loadImage("plantilla00.png"); // plantilla cuadrado refe + user
user = loadImage("plantilla2.png");
cuadro = loadImage("cuadro1png.png");
edrtext = loadImage("textoedr.png");
image(fondo,0,0,1404,872);
font1 = loadFont("Helvetica-12.vlw");
font2 = loadFont ("Helvetica-BoldOblique-24.vlw");
values = loadJSONArray("dataedr1.json");
image(cuadro, 565,230,310,310);
for (int i = 1; i < imgCount; i++) {
imgs[i] = requestImage("img"+nf(i,1)+".jpg");
}
for (int i = 1; i < imgCount2; i++) {
img01[i] = requestImage("data"+nf(i,1)+".png");
fill(0);
}
for (int j = 0; j < values.size(); j++) {
JSONObject ig = values.getJSONObject(j);
int id = ig.getInt("id");
String name = ig.getString("name");
println(id + ", " + name);
}
}
void draw() {
if(pmouseX != mouseX) {
if(imgActual < imgCount-1){
imgActual++;
image(imgs[imgActual], mouseX, mouseY, 65,65);
image(imgs[imgActual], 600,260,250,250);
}else{
imgActual=0;
}
println (imgActual);
}
Thanks again!