We are about to switch to a new forum software. Until then we have removed the registration on this forum.
What I'm trying to accomplish looks something like this. However, after trying out several methods there's always something that goes wrong and I just can't figure it out.
PImage happiness;
PImage sorrow;
int x = 250;
int y = 250;
Happiness happy1;
Sorrow sorrow1;
void setup(){
size(500,500);
smooth();
happiness = loadImage ("happiness0.png");
sorrow = loadImage ("sorrow1.png");
createMask();
}
void draw (){
happy1.display();
sorrow1.display();
happy1.godname();
sorrow1.godname();
}
void createMask() {
happy1 = new Happiness (happiness, x, y);
sorrow1 = new Sorrow (sorrow, x , y);
}
//Base Class
abstract class Masks {
PImage masksImage;
PVector center;
PFont font;
Masks(PImage _image, int x, int y) {
masksImage = _image;
center = new PVector (20, 5);
}
void display () {
image(masksImage, center.x, center.y);
}
abstract void godname(); {
font = loadFont("Algerian-20.vlw");
}
}
//Class 1
class Happiness extends Masks {
Happiness(PImage image, int x, int y) {
super (image, x, y);
}
void godname () {
if (mousePressed == true) {
textFont(font);
fill(0);
text("Eudaemonia", 195, 150);
} else {
fill (#f3f3f4);
}
}
}
Answers
There are many logical problems in your classes!
But main offender is that you're not storing all the parameters passed to the constructors!
Thanks for the reply. This is attempt #1 which still isn't working out: