How do I Switch between Layers Cleaner

Get help using Construct 2

Post » Mon Feb 23, 2015 6:15 am

Hi all, so I have an inventory screen so when certain icons are clicked this inventory screen on another layer becomes visible (Initial on load up is invisible). Is there a cleaner way to switch back and forth between layers instead of coding visible, invisible, visible for layers over and over? I saw in system settings load previous load out but nothing for load previous layer. Thanks in advance and I appreciate all your help so far.
B
19
S
10
G
1
Posts: 24
Reputation: 2,203

Post » Mon Feb 23, 2015 7:38 am

Not really sure i understand what you mean, but the way i make UI elements such as an inventory screen, is to design it using whatever is needed and place it outside the play area, the exact way I want it to appear on the screen when the player opens it, Then ill put it on a layer normally named "Hud" as its the layer with parallax of 0,0, and then I pin all the elements to the background (A sprite or more commonly a 9-patch) of what controls the particular UI element during start of layout.

After that I just make a simple function that will either hide or show (Move off screen / on screen) the element when needed. If I need the UI element on more layouts, I simply make all of it global and include the event sheet that controls it.
So whenever you have to use the hud, I just make a call to a function "Show/hide inventory" for instant and it will automatically switch between showing or hiding it. Which can be done with just checking whether its "On screen" or not. And in the case that its going to show the "Inventory" in this case, I would hook it up to whatever would be needed when the inventory is shown. For instant load all the items carried, calculate weight etc etc.
B
44
S
11
G
2
Posts: 1,181
Reputation: 6,826

Post » Mon Feb 23, 2015 4:16 pm

Thanks for your help. So my inventory screen actually covers the whole screen, not just a small HUD. So you are saying I can create this outside the layout and write a code that will show this in the window view when needed? That would be great if you could explain just a little more on how do this.
B
19
S
10
G
1
Posts: 24
Reputation: 2,203

Post » Mon Feb 23, 2015 4:58 pm

In the case that it filling the whole screen I would make it a bit different. Since if you have more huds, i would reuse the background and instead use a smaller sprite to control the Hud, but basically its the same solution.


Hud_control.capx
You do not have the required permissions to view the files attached to this post.
B
44
S
11
G
2
Posts: 1,181
Reputation: 6,826

Post » Mon Feb 23, 2015 5:16 pm

Thanks for the quick reply! I will try my best to work this out using your capx.
B
19
S
10
G
1
Posts: 24
Reputation: 2,203


Return to How do I....?

Who is online

Users browsing this forum: BlueGuy3, ColombageEnPLS, FlyingRam and 7 guests