Can I traverse an array of position data within a touch event to see if my touch hits a certain button?
              in 
             Programming Questions 
              •  
              1 year ago    
            
 
           
             Hopefully the thread title isn't too confusing... What I've done is placed a rect, which I am treating like a button, and checking to see if the touch event happens within it's boundaries. I then want to traverse an array of Strings that I already have established and see if any of the country names in that array match the title of the button I pressed (The title gets it's String from currentCountries[0][0], so I used it in the comparison).
            
             
            
            
             
            
            
             
              
             
             
              
             
            
             
            
            
 
            
           
             So I'm curious... can I search an entire array of Strings (countries[] is 232 Strings long) within an event method to see if any of them contain the String I'm looking for?
            
            
              void touchDown(int ID, float xPos, float yPos, float xWidth, float yWidth){
             
             
                if((xPos > titleRowPlotX1 && xPos < titleRowPlotX2) && (yPos < titleRowPlotY1 && yPos > titleRowPlotY2)){
              
              
                    for(int i = 0; i < countries.length; i++)
              
              
                     if(countries[i] == currentCountries[0][0])
              
              
                     {
              
              
                       println(currentCountries[0][0]);
              
              
                       showCountries[i] = !showCountries[i];
              
              
                       print(countries[i]);
              
              
                     } 
              
              
                  }  
              
             
              }
             
            
             If anyone is curious, I am ultimately trying to get an event method which will work for touching or clicking a row within two columns of country names. This will turn on or off an accompanying  graph of data for that country; effectively this will work as a filter for the graph. Right now, I am just trying to get one, simple button to do this.
             
             
            
 
            
              
              1  
            
 
            