Scrollbar to control appearance/removal of objects
in
Programming Questions
•
1 years ago
Hey everyone! Really need some help :)
I've built in a scrollbar (used an example from Reas & Fry's book) so that I can control the appearance of objects.
Basically, as the value of the scrollbar increases, the number of objects being shown also increases (the position of the objects are being retrieved from a text file and placed in an array).
What I need is that, when the scrollbar value decreases, all the objects that were previously drawn but do not corresponde to the scrollbar's actual value be removed. What happens now is that the objects are still drawn, but in reverse order.
Am I making any sense? Here's what I got:
println(posactual);
for (int i = 0; i < posactual ; i+=amosP) {
String[] pieces = split(posicoes[i], ';');
int x = int((float(pieces[posX_Pos]))/racioMapa);
int y = 1000/int(racioMapa)-(int(float(pieces[posY_Pos])/racioMapa));
int z = int(pieces[jogPos]);
switch(z) {
case 1:
fill (0, 0, 255); //BLUE
strokeWeight(0.5);
circulo = new Circulo (x, y, ellip_w, ellip_h);
circulo.display();
break;
case 2:
fill (0, 255, 0); //GREEN
strokeWeight(1);
circulo = new Circulo (x, y, ellip_w, ellip_h);
circulo.display();
break;
}
}
Some of the info related to the object creation and others is missing, but I'll fill in the rest if necessary :)
I've built in a scrollbar (used an example from Reas & Fry's book) so that I can control the appearance of objects.
Basically, as the value of the scrollbar increases, the number of objects being shown also increases (the position of the objects are being retrieved from a text file and placed in an array).
What I need is that, when the scrollbar value decreases, all the objects that were previously drawn but do not corresponde to the scrollbar's actual value be removed. What happens now is that the objects are still drawn, but in reverse order.
Am I making any sense? Here's what I got:
String[] posicoes = loadStrings("posicoes.csv");
float posactual=(posicoes.length*pos1)/100; // value of scroll is equivalent to a value in the array
println(posactual);
for (int i = 0; i < posactual ; i+=amosP) {
String[] pieces = split(posicoes[i], ';');
int x = int((float(pieces[posX_Pos]))/racioMapa);
int y = 1000/int(racioMapa)-(int(float(pieces[posY_Pos])/racioMapa));
int z = int(pieces[jogPos]);
switch(z) {
case 1:
fill (0, 0, 255); //BLUE
strokeWeight(0.5);
circulo = new Circulo (x, y, ellip_w, ellip_h);
circulo.display();
break;
case 2:
fill (0, 255, 0); //GREEN
strokeWeight(1);
circulo = new Circulo (x, y, ellip_w, ellip_h);
circulo.display();
break;
}
}
Some of the info related to the object creation and others is missing, but I'll fill in the rest if necessary :)
1