Hi
Not sure if this is the correct forum for this topic, maybe in programming? I'm attempting a simple proof of concept and will extend to more complex designs once i get my head around how to do it: I'd like to control the x & y location of a point with a slider. Please take a look at my code and tell me why the point does not move? (totally confused noob here)
Thanks to
st33d for the base code which I modified (
http://processing.org/discourse/yabb2/YaBB.pl?num=1218148740)
import processing.opengl.*;
// Magic expanding array declared here
ArrayList points;
// To operate on an item in an ArrayList we need a dummy object
Point tempPoint;
import controlP5.*;
ControlP5 controlP5;
int sliderValue = 100;
// Read tin
void setup(){
size(200, 200);
background(255);
controlP5 = new ControlP5(this);
controlP5.addSlider("sliderValue",0,width,sliderValue,0,(height-10),width,10);
points = new ArrayList();
points.add(new Point(sliderValue, sliderValue));
}
// Loop
void draw(){
//print sliderValue to test if variable is changing
println(sliderValue);
// use the dummy object to look inside the ArrayList and modify x,y
tempPoint = (Point)points.get(0);
tempPoint.x = sliderValue;
tempPoint.y = sliderValue;
//render point
point(tempPoint.x, tempPoint.y);
}
// Generic little class
class Point{
float x, y;
Point(float x, float y){
this.x = x;
this.y = y;
}
}
Thanks so much for the help!
1