Question about a level selection screen

Get help using Construct 2

Post » Thu May 10, 2012 11:49 pm

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!
B
3
Posts: 5
Reputation: 410

Post » Fri May 11, 2012 12:18 am

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.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri May 11, 2012 1:18 am

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

Thanks :D
B
3
Posts: 5
Reputation: 410

Post » Fri May 11, 2012 2:46 am

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:
B
3
Posts: 5
Reputation: 410

Post » Fri May 11, 2012 6:39 am

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.
B
14
S
1
G
2
Posts: 85
Reputation: 2,810

Post » Fri May 11, 2012 3:35 pm

[QUOTE=Spudnickator] 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:[/QUOTE]

Sounds like you could avoid that by using booleans like you originally suggested, have you tried that?
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri May 11, 2012 3:46 pm

[QUOTE=Nimtrix] Have one global variable that keeps track of what level the player is coming from[/QUOTE]

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.
B
73
S
20
G
10
Posts: 524
Reputation: 9,896

Post » Fri May 11, 2012 4:33 pm

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.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri May 11, 2012 5:35 pm

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
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Fri May 11, 2012 9:14 pm

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!

B
3
Posts: 5
Reputation: 410

Next

Return to How do I....?

Who is online

Users browsing this forum: Justin1967 and 29 guests