A layout for each level?

Get help using Construct 2

Post » Sun Apr 07, 2013 4:53 pm

Hi, I want some advice on how best to use layouts. I currently have 3:

Menu
Level 1
Level 2

Obviously my menu is very different to the others. It has a start button and is what the player will see first. And also what they will see when they die.

Level 1 has my character, the game level, and also lots of global elements that make up the HUD. I've made these elements global, so that I don't have to duplicate them on every other level. Because if I eventually have 20 levels, and want to change the layout of the HUD, I'll have to change each one!

So Level 2 is very basic, it just has the character and the level. No global elements. But when you play the game, you'll see these global elements as it'll pick them up from Level 1.

When the player goes back to the menu though, all of the global elements still show, overlapping the menu!

I wondered if anyone else has had this exact same problem? And how have you solved it?
B
12
S
2
G
3
Posts: 86
Reputation: 2,955

Post » Sun Apr 07, 2013 5:24 pm

The simplest way I can think to address this "problem" (technically it's a feature more than anything) is to hide the UI elements when you don't need them.

Since you're still using the free version of C2 you won't have access to families, but you can create an event in your menu event sheet that, on the start of the layout, sets each UI element to invisible (families would let you do this as a single action). Then just make sure that you do the opposite in each actual level's event sheet.

If these are UI elements that are interactive, then add a condition to their interaction events that checks if they're visible before performing the action.
B
56
S
15
G
10
Posts: 910
Reputation: 11,972

Post » Mon Apr 08, 2013 5:54 pm



Haha yeah you're right, it's not a problem, as it's doing what's intended! Although it does provide something for me to work around.

I suppose it's not a massive deal for me to include the elements on every layout, I'm just worried about the problems that happen when you multiply things up. I might have 100 layouts, and then want to start changing things, and have to then change the same thing on 100 layouts!

What might be best to do is to add the interface elements by an event. Is that a fairly normal thing to do?
B
12
S
2
G
3
Posts: 86
Reputation: 2,955

Post » Mon Apr 08, 2013 6:13 pm

Making, for example, the UI as a global sprite object on your menu, or loading screen, and then set it invisible, and only visible when on purpose may work.

Did you tried it?
ImageImageImageImageImageImage
B
93
S
20
G
12
Posts: 1,212
Reputation: 18,482

Post » Mon Apr 08, 2013 8:56 pm

The way I'd do it is forget the global objects and instead spawn the UI objects with events on start of layout. I just can't stand having invisible UI objects in my menu :D
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Mon Apr 08, 2013 8:59 pm

onion, you definitely don't want to add your UI elements per layout. That is going to be an issue as your project grows.

Your options are to use global objects and just hide/show them as necessary, or, yes, use events to build them as necessary. I chose the the latter and it works well enough for me.
B
56
S
15
G
10
Posts: 910
Reputation: 11,972

Post » Mon Apr 08, 2013 10:31 pm

I did an eventsheet exclusively for UI and then I INCLUDE it to the STAGE eventsheet and works flawless too.TELLES08082013-04-08 22:40:26
ImageImageImageImageImageImage
B
93
S
20
G
12
Posts: 1,212
Reputation: 18,482

Post » Tue Apr 09, 2013 5:05 pm

Okay thanks guys, it sounds like a good idea would be to load interface elements from the event sheet. Then it'll give me more flexibility for changing when the project gets bigger.

So let me just check though, the best way to do this is on start of layout, system > create new object > sprite1etc at (x,y)

And also have an unused instance of this sprite positioned off the layout somewhere, just so it will be included in the project?
B
12
S
2
G
3
Posts: 86
Reputation: 2,955

Post » Tue Apr 09, 2013 5:49 pm

I would just use a separate layer for the UI elements. Then when you don't need them you just hide that layer. Helps me when working in the editor as well, I can lock that layer and make it invisible in the editor and not worry about it when adding in tiles.

Then I just have a template layout that I start each level layout from that has the UI layer built in.

If later on in a different level you decide you need to tweak the UI, then just modify the UI layer for that particular level.

B
5
S
1
G
1
Posts: 28
Reputation: 615

Post » Tue Apr 09, 2013 5:54 pm

Problem is though @spartyon, what if I have a hundred levels and want to change how the interface elements look. I'd have to change it on 100 layouts! I much prefer @sqiddster's idea of spawning it from an event sheet, then I only have 1 place to change.
B
12
S
2
G
3
Posts: 86
Reputation: 2,955

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests