Hi there,
I'm currently working on a uni project that is using tuioZones and oscP5 as libraries. I came across some problems when I try to use the isZoneToggleOn(String zName) method. Once the zones are toggled on, even I touch on the zones again, they won't toggle off.
these are parts of my code inside a class
Code:
void setting(){
statusH = 50;
//Arrays for the share list
positions = new String[] {
"Chief", "Attendant", "Resident", "Intern" };
chief = new String[] {
"Martin", "Elmo" };
docImg = loadImage("doc.png");
hole = loadImage("pigeon_hole.png");
zones.setZone("shareList", -100, -100, -10, -10);
zones.setZone("pos0", -100,-100, 10, 10);
zones.setZone("pos1", -100,-100, 10, 10);
zones.setZone("pos2", -100,-100, 10, 10);
zones.setZone("pos3", -100,-100, 10, 10);
zones.setZone("hole", -100, -100, 10, 10);
}
Code:
void drawZone(){
if(zones.isZoneToggleOn("pos0")){
for(int j=0; j< chief.length; j++){
fill(255,0);
stroke(100, 150, 250);
strokeWeight(3);
rect(zones.getZoneX("pos0"), zones.getZoneY("pos0"), zones.getZoneWidth("pos0")-2.5, zones.getZoneHeight("pos0")-2.5);
doc = "chief" + j;
zones.setZone(doc, cellX, cellY, cellW-5, (cellH/4)*3);
fill(150);
strokeWeight(2);
stroke(50);
zones.drawRect(doc);
image(docImg, zones.getZoneX(doc)+5, zones.getZoneY(doc)+5, zones.getZoneHeight(doc)-10, zones.getZoneHeight(doc)-10);
fill(255);
textFont(font,20);
text(chief[j], zones.getZoneX(doc)+gap+30, zones.getZoneY(doc)+(zones.getZoneHeight(doc)/4)*3);
cellY = cellY + (cellH/4)*3;
}
}
}
Code:
void updateZones(){
for(int j=0; j< chief.length; j++){
doc = "chief" + j;
if(zones.isZoneToggleOn(doc)){
fill(255, 0);
strokeWeight(2);
stroke(100, 150, 250);
zones.drawRect(doc);
zones.setZoneData("hole", zones.getZoneX(doc)-statusH, zones.getZoneY(doc), zones.getZoneWidth(doc), zones.getZoneHeight(doc)*3);
fill(255);
textFont(font,15);
text(text(chief[j], zones.getZoneX("hole")+70, zones.getZoneY("hole")+20);
}
}
}
in this part of the code above, when a position array for a category of doctors(i.e Chief) is selected then the according array of names should appear along with creating a zone for each.
When a name(zone) is toggled on, the 'hole' zone should snap to the correct position as called in the setZoneData().
Okay, now, here is the problem. I should be able to toggle off the name(zone) which should make the name(zone) as well as the 'hole' disappear, however the name(zone) cannot be toggled off and the blue outline remains(zones.drawRect(doc)
. WHY?!! The logic seems to be correct.
PLEASE HELP!