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 › Replacing an image over another & mouse movement
Page Index Toggle Pages: 1
Replacing an image over another & mouse movement (Read 1065 times)
Replacing an image over another & mouse movement
Nov 9th, 2009, 3:24pm
 
Very new to processing, and am trying to create a flipbook animation of a man dancing using several images (using arrays) and am wondering a few things;

*how to replace the image after it has been used so that it runs through a few images without overlapping.

* how to make the movement of the mouse to determine the frame rate, so that the man dances faster when the mouse is moving and stops when the mouse stops. Embarrassed

any help will be greatly appreciated!
Re: Help Severely Needed
Reply #1 - Nov 9th, 2009, 3:46pm
 
Do it like this but think of the ints as images

move the mouse on the X axis to control the speed.

int[] numbers = {
 9,8,7,6,5,4,3,2,1,0 };
PFont font = createFont("Arial",62);

void setup(){
 size(300,300 );
 textFont(font);
 textMode(CENTER);
}
float i = 0;
void draw(){
 background(255);
 fill(0);

 text(numbers[(int)i],width/2,height/2);
 
 i+= map(mouseX,0,width,0,1);
 if(i>=numbers.length )i=0;
}

Re: Replacing an image over another & mouse movement
Reply #2 - Nov 9th, 2009, 4:46pm
 
have tried to put this code into my own but have been unable to make it move the image.... my code is as followed.... any help is much much appreciated!

int numFrames = 7;  // The number of frames in the animation
int frame = 0;
PImage[] images = new PImage[numFrames];

int value = 0;

void setup () {
 size (500, 400);
 PImage b;
b = loadImage("disco background.gif");
 background (b);
 frameRate (1);

}
 

void draw() {
   
 images[0] = loadImage ("1.gif");
 images[1] = loadImage ("2.gif");
 images[2] = loadImage ("3.gif");
 images[3] = loadImage ("4.gif");
 images[4] = loadImage ("5.gif");
 images[5] = loadImage ("6.gif");
 images[6] = loadImage ("7.gif");
 
    frame = (frame+1) % numFrames;  // Use % to cycle through frames
 image(images[frame], 150, 50);
}




also any idea how to make the image to stop overlapping, to place the background over it each time
?

thanks again!
Re: Replacing an image over another & mouse movement
Reply #3 - Nov 9th, 2009, 5:48pm
 
i dont get any problems.
you should move your  images[0] = loadImage ("1.gif"); to setup though.
but i can see an animation. Did you remove the frameRateSpeed on mousemovement on purpose?

To place the background over the images each frame, just call background(b) again at the beginning of draw()
Page Index Toggle Pages: 1