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

  • SEARCH
  • Home
  • 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 3978928
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:06:27+00:00 2026-05-20T05:06:27+00:00

am having game with 10 levels. i want to change the second level lock

  • 0

am having game with 10 levels. i want to change the second level lock image to unlock when first level is completed.

am using 20 images ( 10 locked and 10 unlocked).

am using cc menus to display the number images.
for example(code):-

 CCMenuItemImage *startButton12 = [CCMenuItemImage itemFromNormalImage:@"ten_new-lock.png"
        selectedImage:@"ten_new-lock.png" target:self
        selector:@selector(ten:)];

    menu1  = [CCMenu menuWithItems: startButton3,startButton4,startButton5,startButton6,startButton7,startButton8,startButton9,startButton10,startButton11,startButton12, nil];
      menu1.position = ccp(240,30);
      [menu1 alignItemsHorizontally];
      [menuLayer1 addChild: menu1];

am using below code for remember the level completed.

 int lastLevelCompleted= [[NSUserDefaults standardUserDefaults] integerForKey:@"levelCompleted"];
    if(currentLevel >lastLevelCompleted){
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     [defaults setInteger:currentLevel forKey:@"levelCompleted"];

**now, how to change the lock to unlock images.

( if am doing here wrong)there is other way to solve means provide that. i have to implement that one.**

  • 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-20T05:06:28+00:00Added an answer on May 20, 2026 at 5:06 am

    I have the same idea in one of my games. I solved it with separate lock and done icons that I have positioned on top of each menu item that represents a level.

    Just create your menu items normally. Don’t try to represent locked or done states with the menu item’s icon. Instead create a smaller locked and done icons that you will instantiate as sprites and position on top of each menu item.

    Here is the relevant part of my menu layer’s init method (I’m using a sprite atlas to store all my images):

    // I save the state of each level as a character in a NSMutableString: 
    self.completedState = 0x0043; // "C" (Completed)
    self.openState = 0x004f; // "O"
    self.lockedState = 0x004c; // "L"
    self.dungeonAvailabilityState = @"COLLLLLLLLLLLLLLLL"; // in reality I get this string from a global object
    
    // calc the position for the dungeon icon at row, column
    x = (column*56)+148;
    y = 244-(row*56);
    
    // get the dungeon state
    stateIndex = (row*columns)+column;
    dungeonState = [self.dungeonAvailabilityState characterAtIndex:stateIndex];
    
    
    // calc the position of the badges using offset from the menu item's icon
    lockedX = x - DungeonsScreen_BadgeXoffset;
    lockedY = y - DungeonsScreen_BadgeYoffset;
    doneX = x - DungeonsScreen_BadgeXoffset;
    doneY = y + DungeonsScreen_BadgeYoffset;
    
    if (dungeonState == self.lockedState) {
     // add the lock icon
     [super badgeIconFromFrame:@"icon_lock.png" xPos:lockedX yPos:lockedY spriteTag:t++];
    }
    

    and my helper method badgeIconFromFrame looks like this:

    - (void) badgeIconFromFrame:(NSString*)spriteName xPos:(float)x yPos:(float)y spriteTag:(int)t {
            CCLOG(@"%@: %@", NSStringFromSelector(_cmd), self);
    
            CCSprite* badgeSprite = [CCSprite spriteWithSpriteFrameName:spriteName];
            badgeSprite.position = CGPointMake(x, y);
            [self addChild:badgeSprite z:zIndexDecoration tag:t];   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some problems with users cheating my online game by using macros to
this is the second game that I'm having issues with in the same area...
Does a game need to have levels? Does having no levels put people off?
I want to use in my game effect of perspective view by using few
I m having a game which requires rounds being clicked by players . It
I'm having problems getting my game engine to run on my brother's machine, which
I'm having difficulty with an architectural decision for my C# XNA game. The basic
I am creating a Stratego Game and am having trouble creating an algorithm that
I am having a logic issue with my UNIX number guessing game. The menu
I'm writing a hangman game. I'm having a logic fail, both with myself and

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.