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.
Page Index Toggle Pages: 1
mouse and gifs (Read 442 times)
mouse and gifs
Aug 28th, 2006, 3:29pm
 
Hi!
im new to processing but want to start building an animated gif game.
I first want to learn how to drag and drop an animating gif on screen and pick it up and place it again.
Is it simple code?
~C
Re: mouse and gifs
Reply #1 - Aug 29th, 2006, 12:24am
 
http://processing.org/learning/index.html
on Images, Is this what you are talking about ?
Re: mouse and gifs
Reply #2 - Aug 29th, 2006, 7:22am
 
with this example but use a gif instead of a box? how do you replace this?
C

float bx;
float by;
int bs = 20;
boolean bover = false;
boolean locked = false;
float bdifx = 0.0;
float bdify = 0.0;


void setup()
{
 size(200, 200);
 bx = width/2.0;
 by = height/2.0;
 rectMode(CENTER_RADIUS);  
}

void draw()
{
 background(0);
 
 // Test if the cursor is over the box
 if (mouseX > bx-bs && mouseX < bx+bs &&
     mouseY > by-bs && mouseY < by+bs) {
   bover = true;  
   if(!locked) {
     stroke(255);
     fill(153);
   }
 } else {
   stroke(153);
   fill(153);
   bover = false;
 }
 
 // Draw the box
 rect(bx, by, bs, bs);
}

void mousePressed() {
 if(bover) {
   locked = true;
   fill(255, 255, 255);
 } else {
   locked = false;
 }
 bdifx = mouseX-bx;
 bdify = mouseY-by;

}

void mouseDragged() {
 if(locked) {
   bx = mouseX-bdifx;
   by = mouseY-bdify;
 }
}

void mouseReleased() {
 locked = false;
}

Re: mouse and gifs
Reply #3 - Aug 29th, 2006, 1:05pm
 
like that ?
http://processing.org/learning/examples/sprite.html
Re: mouse and gifs
Reply #4 - Aug 29th, 2006, 1:17pm
 
yes like that only you can pick up the picture liek a puzzle piece and drop it with the mouse
Page Index Toggle Pages: 1