How do I draw my inventory when I switch layouts?

0 favourites
  • 8 posts
From the Asset Store
You need this package if you want to program a Street Fighter or battle game.
  • Hi all,

    I am currently storing the player's inventory in an array and displaying their inventory in a bar at the bottom of the screen.

    On start of my game I trigger an "itemPickUp" function so the player is stocked with their default items. The problem is when i switch layouts, these items get destroyed. They are still stored correctly in the array but I'm not sure how to draw them again to the screen.

    I was hoping "on start of layout" would trigger on start of any layout but this is not the behaviour.

    Is there a way to trigger an event on start of any layout? Or is there some better way I could be doing this?

    Thanks in advance for your help!

  • You can either make the item bar global so that it is showing the same data through layouts without calling the function again (objects are not destroyed), or you can add the function on start of layout to all event sheets that are linked to the layouts.

  • Thanks for your response!

    What's weird is I am using "on start of layout" function to stock the default items. And even though both layouts are using the same event sheet the items still get destroyed and don't get re-stocked when I switch layouts.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Difficult to guess this without the file but I would make sure te second layout is definitely linked with the event sheet and not set to 'none'. If it is actually linked then there must be a problem with data like with the array or something.

  • I've double checked and it is using the correct event sheet.

    Here is a link to my game file if you don't mind taking a look: drive.google.com/file/d/1ngS6ldw6lmu6gQmtYx-3yKLeyjdmpW2D/view

    You can switch between two layouts by walking inside/outside the house.

    Thanks!

  • It's because at the start of the game the inventory doesnt contain the name, but once theyre added then the inventory does contain the name, it doesnt run the logic for creating the objects on future layouts.

  • Ah okay.

    I really want to trigger this (and other) actions on the start of any layout but there doesn't seem to be a trigger for this. Is there one?

  • I figured it out!

    They actually were there they were just being hidden behind the inventory because for some reason when you switch layouts it changes the Z order. Weird...

    But anyway it's working. Thanks for your help!

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