Text change colour and stay on top
in
Programming Questions
•
8 months ago
Hello i've got this script but when I run it the black scrolling circle scrolls infront of the text how do I make the text a seperate colour and have it so its infront of the scrolling ball. Also how can I make the text appear and dissapear in relation to an amount of time?
Thanks for anyhelp
//Ball variables
int x,y;
Circle myCircle2 = new Circle(x, y, 30);
Circle myCircle1 = new Circle(200, 200, 20);
//Image variables
PImage img;
void setup() {
size(500, 500);
img = loadImage("image1.jpg");
x = width/2;
y = height/2;
noStroke();
}
void draw() {
background(0, 0, 0);
image(img,0, 0);
myCircle2.x = x;
myCircle2.y = y;
y--;
if(y < -50)y = height+50;
myCircle1.x = mouseX;
myCircle1.y = mouseY;
if(dist(myCircle1.x, myCircle1.y, myCircle2.x, myCircle2.y) < myCircle1.r + myCircle2.r) {
strokeWeight(2);
stroke(0, 255, 0);
textAlign(CENTER);
textFont(createFont("Arial", 18));
text("You Lose.",width/2,150);
line(100, 100, 400, 100);
line(100, 200, 400, 200);
line(100, 100, 100, 200);
line(400, 200, 400, 100);
fill(0);
noStroke();
} else {
fill(0, 255, 0);
noStroke();
}
myCircle1.render();
myCircle2.render();
}
class Circle {
float x;
float y;
float r;
Circle(float xpos, float ypos, float radius) {
x = xpos;
y = ypos;
r = radius;
}
void render() {
ellipse(x,y,r*2, r*2);
}
}
1