How do I Switch between Layers Cleaner

0 favourites
  • 5 posts
From the Asset Store
Toggles Dials Switches and Alerts ! A foundational sound grouping of Analog type switches and Steampunk effects
  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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.

    [attachment=0:2f7jbjlq][/attachment:2f7jbjlq]

  • Thanks for the quick reply! I will try my best to work this out using your capx.

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