cycle multiple images + single mouse press

edited November 2013 in Questions about Code

So I have a switch/case that is cycling through 3 images within the same coordinates when the mouse is pressed. My issue is that as soon as the condition in case 1 is met (mouse tapped), the switch/case cycles through all the cases until the last one. Here is my code below:

int counter_channels =1;


switch(counter_channels) {

    case 1:


      channelOne.display(0, 0);


        if (mouseX > displayWidth/1.2-channelOne.getWidth() && mouseX < displayWidth/1.2+channelOne.getWidth() && 
          mouseY > displayHeight/1.55-channelOne.getHeight() && mouseY < displayHeight/1.55+channelOne.getHeight()) {


 counter_channels++;


}

      break;

    case 2:


      channelTwo.display(0, 0);


        if (mouseX > displayWidth/1.2-channelTwo.getWidth() && mouseX < displayWidth/1.2+channelTwo.getWidth() && 
          mouseY > displayHeight/1.55-channelTwo.getHeight() && mouseY < displayHeight/1.55+channelTwo.getHeight() ) {


          counter_channels++;


      }




      break;


    case 3:
      int xposTV= 171;
      int yposTV = 150;



      fill(127);
      rect(0, 0, xposTV, yposTV);


    }
Tagged:

Answers

Sign In or Register to comment.