Question about a level selection screen

0 favourites
  • 12 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • I have a simple level selection screen where if you click the name of the level you go straight to that level, and then when the level is finished you return to the level selection screen.

    My problem is that I want the colour of the box the level name is in to change after completion of the level. I have sprites set up so all I need to do for this is to make the right sprite visible when a level is completed, however I'm unsure how to do this.

    My first idea was to use a boolean on each of the sprites and then have that be set to visible when the level is complete, however this obviously doesn't work across separate layouts.

    I assume I need to use global variables, but I'm unsure how to do this. I can see it being easy to do if the levels had to be completed in numerical order, but they can be done in any order so I'm unsure how to accomplish this.

    Thanks in advance!

  • Have one global variable that keeps track of what level the player is coming from, and one global variable that is set to 1 only if the level was completed (and set to 0 after the frame has been set correctly). Then you should have enough information to point out which sprite should change frame.

  • Ah okay! That makes sense, not sure why I didn't think of that. I'll try that now.

    Thanks :D

  • Gaah, tried that and a few other things and it works to start with, but then I run into a problem.

    If I beat one level it's fine, but when I beat a second level the changes to the colour of the first level revert to default, and then it shows the second level as it should, and it keeps doing that. Any help? D:

  • Wanna post your capx, or PM it to me and I'll fix it up? The job should only take a minute--it'd be longer to explain it than to actually fix it myself, and for you to see how it was done.

  • Gaah, tried that and a few other things and it works to start with, but then I run into a problem.

    If I beat one level it's fine, but when I beat a second level the changes to the colour of the first level revert to default, and then it shows the second level as it should, and it keeps doing that. Any help? D:

    Sounds like you could avoid that by using booleans like you originally suggested, have you tried that?

  • Have one global variable that keeps track of what level the player is coming from

    A bit unnecessary. A far easier way of accomplishing it would be to have one global variable for each level.

    When a level is completed, change the respective global variable to 1 (or whatever you have to represent "completed") in the same event that decides that the level is completed, before returning to the level select screen.

  • To keep the changes over layouts, you could either do as inkBot says and make lots of global variables, or you could make your level objects global. It will then work with only 1 global var for the levels, but you'll have to move the global objects on layout change. Don't know what I would do, depends on how many levels I'd have to deal with.

  • yeah if you dont ever intend to make more lvls or add more after the games "finished" then Id go with the global per level approach.

    I prefer to make a system extendable from the outset just incase I do need it to be later on down the road.

    Id probably test if a global is greater than 0 when the level select screen starts. If it is Id know that number is the last level I did. Id only change that number from 0 if the level was completed.

    Then Id enabled the level complete sprite based on the number in the global then set the global back to 0

  • I've gone with the global per level approach and it all works good, thanks for the suggestions everyone! I'm curious as to how doing it this way wouldn't allow for adding more levels once the game is finished, surely I could just keep adding more variables? Not that I plan to anyway, this is just a first attempt at fiddling around with the program more than anything!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • yeah you could just add more lvls like that later the problem is say youve made a game and its kinda popular but you havent touched the "code" for it for months then one day you decide to go add some more lvls but you cant remember everything you had to add and/or change to make it work like the rest of the lvls

    You waste time goin back over your own old work tryin to figure out how you did it before you can even get back to what you wanted to do which was simply addin more content.

    The method I suggested puts everything in place from the beginning so if you want to add more lvls later all you have to do is make those new maps just like you did the original ones and itll work.

    Itll also save you the problem of addin a new lvl then testing it only to find out once you finish it it doesnt work like the rest cause you forgot to add somethin (like a new global) cause your mind was on level creation not code

  • That should work, but I'm having a very similar issue here --

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)