ria_nikki_pam
YaBB Newbies
Offline
Posts: 6
Re: count mousePressed
Reply #2 - May 23rd , 2007, 9:35am
hey, thanks for the quick reply. i've included the code you put up,and it works, it knows its counting, but it doesnt do anything with it... i need it to recognise it and then change the output. heres what i've got so far, but it continues to play the same images. i assume i need to put 'counter' in draw with the if / else statements, however i'm not quite sure what to do with them after that... thanks! Balloons series1, series2; float xpos, ypos; //SET AN INT VARIABLE int counter; void setup() { size(450, 450); series1 = new Balloons("balloon", 5); series2 = new Balloons("ball", 5); } void mouseReleased() { counter = counter + 1; println("one"); } void draw() { counter = 0; if(mousePressed) { frameRate(7); series1.display(xpos-series1.getWidth()/2, ypos); } else if (mousePressed) { counter = 1; frameRate(3); series2.display(xpos-series1.getWidth()/2, ypos); } else { //frameRate(1); background(0); //having the value as 500 will make it pause } //println(reading); } class Balloons { PImage[]bal; int frame; int numFrames; Balloons(String imageName, int frameCount){ numFrames = frameCount; bal = new PImage[numFrames]; loadImages(imageName); } void loadImages(String name) { for(int i=0; i<numFrames; i++) { String imageName = name + ((i < 4) ? "" : "") + i + ".jpg"; bal[i] = loadImage(imageName); } } void display(float xpos, float ypos) { frame = (frame+1)%numFrames; image(bal[frame], 1, 1); } int getWidth() { return bal[0].width; } }