Help with my class error?
in
Programming Questions
•
1 year ago
This is my full program and when I run it I get the following error.
My code is below:
The constructor sketch_mar23e.toggle(int, int, boolean) is undefined.
- toggle T;
- void setup() {
- size(400, 400);
- background(255);
- T = new toggle(100, 100, true);
- }
- void draw() {
- T.update();
- T.display();
- }
- class toggle {
- boolean active = false;
- int x;
- int y;
- void toggle(int tempX, int tempY, boolean tempActive) {
- active = tempActive;
- x = tempX;
- y = tempY;
- }
- void display() {
- fill(255);
- stroke(0);
- rectMode(CENTER);
- rect(x, y, 40, 40);
- if(active == true) {
- line(x - 20, y + 20, x + 20, y - 20);
- line(x - 20, y - 20, x + 20, x + 20);
- }
- }
- void update() {
- if(mousePressed) {
- if(mouseX < x + 20 && (mouseY < y + 20) && (mouseX > x - 20) && (mouseY > y - 20) && (active == false)) {
- active = true;
- } else if(mouseX < x + 20 && (mouseY < y + 20) && (mouseX > x - 20) && (mouseY > y - 20) && (active == true)) {
- active = false;
- } else {
- }
- }
- }
- boolean getValue() {
- if(active == true) {
- return true;
- } else if(active == false) {
- return false;
- }
- }
- }
1