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 7644823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:46:57+00:00 2026-05-31T09:46:57+00:00

This has been giving me a headache for about two days now! I have

  • 0

This has been giving me a headache for about two days now!

I have a game with levels. When the level selection scene is loaded, i check the MaxLevelReached int variable.

The first time the user plays, the maxlevelreached variable is 0.

The first level is = 0 so what i do is this when the scene is loaded…

 private int level = 60; 

 if (level >=  maxLevelReached || maxLevelReached == 0){
     box.setColor(0, 0, 0);  
 }
 else
 {
     box.setColor(0, 0.9f, 0);
 }

As you see I check to see if the level is less than or equal to the maxLevel.

So to start off the user should be able to play to the first level, and then when it is completed the second level will be unlocked. I know this seems really simple, but for some reason I’ve been struggling with it.

If the user clicks on a level and it Isn’t unlocked yet, this is how i test to start the level or not..

Log.e("Level:"+levelClicked, "Level");

if(levelClicked >= maxLevelReached){                                                           
    levelClicked = levelToLoad;    
    Intent intent = new Intent(level.this, GameLevel.class);                        
    intent.putExtra("level", levelClicked);                                          
    startActivity(intent);                                                        
 }

This Isn’t working either… For some reason all of the levels are playable when it should only be the first level to begin with.

Here is how I unlock the levels once the previous level is completed..

int CurrentLevel = level+1;
Log.e("Current Level unlocked", String.valueOf(CurrentLevel));
editor.putInt("max_level",CurrentLevel);
editor.commit();

Then I do this in the level selector scene…

int unlockedLevel = preference.getInt("max_level",0);
maxLevelReached += unlockedLevel;

I know this seems like a mess. Indeed I believe that its giving me a headache. Could anyone help me out please?

  • 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-31T09:46:59+00:00Added an answer on May 31, 2026 at 9:46 am

    I think your comparison is wrong.

    if (level >=  maxLevelReached || maxLevelReached == 0)
    

    This reads, if the level the user is on is greater than the max level reached or the max level reached is level zero then allow.

    So it should be < instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems rather simple but it has been giving me a headache. I have
This has been driving me nuts for a week now. I have a class
I have fairly decent C++ skills, but this one cast has been giving me
A php script is giving this array (which has been passed through json_encode() )
This has been driving me crazy for a few days. Why doesn't the following
This has been a rather problematic issue on numerous occasions. We have alot of
This has been driving me crazy for the past few minutes I have a
I hope you will be able to help me, this has been giving me
I was doing some stuff with palindromes: This number 9966006699 has been giving me
I'm sure that this has been asked MANY times before, but it's still giving

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.