We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Moving buttons
Page Index Toggle Pages: 1
Moving buttons (Read 320 times)
Moving buttons
Apr 5th, 2008, 7:21pm
 
I'm doing a gallery. I'd like to be able to click on the Images and have them appear as the background, but I don't know how to create moving buttons.

If I could draw invisible buttons using the Images x, y, width and height. Either by creating buttons or creating rectangles that have a click event.




import fullscreen.*;


int r, k, h;
PImage hud;
PImage[] images = new PImage[20];
FullScreen fs;
PImage bground;

void setup()  {
 size(screen.width, screen.height);
 fs = new FullScreen(this);
 fs.enter();
 background(255);
 colorMode(RGB, 255, 255, 255, 100);
 rectMode(CENTER);
 frameRate(30);
 smooth();

 images[0] = loadImage("andi.jpg");
 images[1] = loadImage("artfinal.jpg");
 images[2] = loadImage("cloud.jpg");
 images[3] = loadImage("dearsam.jpg");
 images[4] = loadImage("easyskankin.jpg");
 images[5] = loadImage("fantastic.jpg");
 images[6] = loadImage("fured.jpg");
 images[7] = loadImage("iandemon.jpg");
 images[8] = loadImage("josh.jpg");
 images[9] = loadImage("link.jpg");
 images[10] = loadImage("pinkelephants.jpg");
 images[11] = loadImage("tessa.jpg");
 images[12] = loadImage("vectorme.jpg");

 hud = loadImage("HUD.png");
 bground = loadImage("blank.jpg");
 
}


void draw()  {
 background(255);
 image(bground, 0, 0);
 r = (height * 3)/4;
 int fr = frameCount % 360;
 int number = 13;
 float[] x = new float[number];
 float[] y = new float [number];


 for(int i = 0; i < number; i++)  {
   int t = fr - (720 / number) * i;
   x[i] = r * cos(radians(t)/2);
   y[i] = r * sin(radians(t)/2);

   image(images[i], x[i], y[i]);
 }

 image(hud, 0, 0, width, height);
}
Page Index Toggle Pages: 1