Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 646041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:34:07+00:00 2026-05-13T21:34:07+00:00

Ok, I’m going to try to make this more clear because my last question

  • 0

Ok, I’m going to try to make this more clear because my last question was extremely confusing. I’ve included a picture this time. Each one of these circles is a UIImageView and they are each assigned a random image which is one of 7 colors. So each circle could be one of 7 colors. I want to make it so that the user has to hit the circles in order of a pre-determined order according to color. For example, blue, green, yellow, pink, purple, orange, red. My HUGE problem is that I can’t seem to figure out how to determine whether or not a color that isn’t supposed to be hit got hit. Is there a way to assign multiple image views the same value and then somehow have an if statement that says….

if(a blue circle is hit && ANY ORANGE CIRCLE IS STILL IN VIEW){
do something
}

The only way I know how to code this would be an insane amount of code, because of all the random images being assigned.

    bluebubble = [UIImage imageNamed:@"bluebubble.png"];
    greenbubble = [UIImage imageNamed:@"greenbubble.png"];
    redbubble = [UIImage imageNamed:@"redbubble.png"];
    yellowbubble = [UIImage imageNamed:@"yellowbubble.png"];
    orangebubble = [UIImage imageNamed:@"orangebubble.png"];
    pinkbubble = [UIImage imageNamed:@"pinkbubble.png"];
    purplebubble = [UIImage imageNamed:@"purplebubble.png"];


    image1 = arc4random()%7;

    if(image1 == 0){
        [test setImage:bluebubble];
    }
    else if(image1 == 1){
        [test setImage:greenbubble];
    }
    else if(image1 == 2){
        [test setImage:redbubble];
    }
    else if(image1 == 3){
        [test setImage:yellowbubble];
    }
    else if(image1 == 4){
        [test setImage:orangebubble];
    }
    else if(image1 == 5){
        [test setImage:pinkbubble];
    }
    else if(image1 == 6){
        [test setImage:purplebubble];
    }

    image2 = arc4random()%7;

    if(image2 == 0){
        [test2 setImage:bluebubble];
    }
    else if(image2 == 1){
        [test2 setImage:greenbubble];
    }
    else if(image2 == 2){
        [test2 setImage:redbubble];
    }
    else if(image2 == 3){
        [test2 setImage:yellowbubble];
    }
    else if(image2 == 4){
        [test2 setImage:orangebubble];
    }
    else if(image2 == 5){
        [test2 setImage:pinkbubble];
    }
    else if(image2 == 6){
        [test2 setImage:purplebubble];
    }

alt text

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:34:07+00:00Added an answer on May 13, 2026 at 9:34 pm

    I think it’s also wise to create a more reasonable way to assign the different color images to your image views, so this solution does both.

    These Should be declared in the header of the class

    NSArray *allCircleImagesViews; // These are suppose to be the onscreen UIImagesViews 
    
    NSArray *circlesByColor;
    NSMutableArray *correctCircles; // The current circles the user is allowed to click
    NSArray *colorOrder; // The order of the colors to click
    int currentColorIndex; // The current index in the order of colors
    

    Now for the functions:
    The first one creates assign the different color images, sets the correct order of the colors, and sets the mechanism to determine if the correct color was clicked

    - (void) populateImages
    {
        NSArray *images = [NSArray arrayWithObjects:
                           [UIImage imageNamed:@"bluebubble.png"],
                           [UIImage imageNamed:@"redbubble.png"],
                           [UIImage imageNamed:@"yellowbubble.png"],
                           [UIImage imageNamed:@"greenbubble.png"],
                           [UIImage imageNamed:@"orangebubble.png"],
                           [UIImage imageNamed:@"pinkbubble.png"],
                           [UIImage imageNamed:@"purplebubble.png"],
                           nil];
    
        NSArray *circlesByColor=[NSArray arrayWithObjects:
                                 [NSMutableArray array],
                                 [NSMutableArray array],
                                 [NSMutableArray array],
                                 [NSMutableArray array],
                                 [NSMutableArray array],
                                 [NSMutableArray array],
                                 [NSMutableArray array],
                                 nil];
        [circlesByColor retain];
    
        // Assign images to circles and set the 
        for (UIImageView *currCircle in allCircleImagesViews)
        {
            int nextIndex = arc4random()%7; 
            currCircle.image = [images objectAtIndex:0];
            [(NSMutableArray *)[circlesByColor objectAtIndex:nextIndex] addObject:currCircle];
        }
    
        // Set the correct order
        NSArray *colorOrder = [NSArray arrayWithObjects:
                      [NSNumber numberWithInt:5], // Pink
                      [NSNumber numberWithInt:0], // Blue 
                      [NSNumber numberWithInt:1], // etc.
                      [NSNumber numberWithInt:4],
                      [NSNumber numberWithInt:2],
                      [NSNumber numberWithInt:3],
                      [NSNumber numberWithInt:6],nil];
        [colorOrder retain];
    
        currentColorIndex = 0;            
        correctCircles = [circlesByColor objectAtIndex:[[colorOrder objectAtIndex:currentColorIndex] intValue]];
    }
    

    The following function takes care of checking if the correct circle was clicked

    - (void) checkCircle:(UIImageView *)clickedImageView
    {
        BOOL result;
    
        if ([correctCircles containsObject:clickedImageView])
        {
            [correctCircles removeObject:clickedImageView];
            result = YES;
        }
        else {
            result =  NO;
        }
    
    
        if ([correctCircles count] == 0)
        {
            currentColorIndex++;
            if (currentColorIndex < 7)
                correctCircles = [circlesByColor objectAtIndex:[[colorOrder objectAtIndex:currentColorIndex] intValue]];
            else
                correctCircles = nil;
        }
    
        if (!result)
        {
            // Wrong circle clicked logic
        }
        else {
            if (!correctCircles)
            {
                // Game won logic
            }
            else {
                // Correct circle clicked logic
            }
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
We're building an app, our first using Rails 3, and we're having to build
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.