Objects and minim library
in
Core Library Questions
•
11 months ago
Hi there!
I`m working on a project for a class with some mates and we are using the minim library to make an interactive app for user to "play" in some way or experiment with drawings and sounds.
The thing is that I can`t get the library to work while working with objects/classes. This is a simple example that shows what the problem is: I have two classes Circulo and Cuadrado, the first one draws an ellipse and the second draws a rectangle, I am trying to make this to also play a sound, I mean, I want that Circulo draw an ellipse and play a sound, and that Cuadrado draw a rectangle and play another sound.
I don`t know where to call for minim library, If i call it inside Circulo or cuadrado then I get errors on the "main" code (which makes sense), also the stop function doesn't work neither in Circulo nor Cuadrado..
If you could give any help with this it`d be great!
thanks!!
"main" CODE
- Circulo juan;
- Cuadrado nico;
- boolean apretadito;
- void setup(){
- size(600,400);
- juan = new Circulo();
- nico = new Cuadrado();
- }
- void draw(){
- background(255);
- smooth();
- if (!apretadito){
- juan.dibujar();
- } else {
- nico.dibujar();
- }
- }
- void mousePressed(){
- apretadito = !apretadito;
- }
CIRCULO
- class Circulo{
- int radio = 50;
- Circulo(){
- radio = 50;
- }
- void dibujar(){
- fill(200,0,0);
- ellipse(width/2, height/2, radio*2, radio*2);
- }
- }
CUADRADO
-
class Cuadrado{
-
-
void dibujar(){
-
fill(0,0,200);
-
rectMode(CENTER);
-
rect(width/2+150, height/2, 100, 150);
-
}
-
}
1