public Switch(MainGround p, boolean set, int x, int y, String l) { status = set; visible = false; parent = p; xPos = x; yPos = y; label = l; onImg = parent.loadImage("img/on_switch.png"); offImg = parent.loadImage("img/off_switch.png"); this.height = onImg.height; this.width = offImg.width; }
public void draw(int x, int y) { setXPos(x); setYPos(y); if (status) { parent.fill(121, 242, 149); parent.image(onImg, xPos, yPos - 7); } else { parent.image(offImg, xPos, yPos - 7); } parent.textSize(10); parent.fill(240); parent.text(label, xPos + width + 8, yPos + (height / 2) + 2); }