How do I get instance var of an object on a different layout

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hey everyone...

    I have the following problem.

    I have different 3 Objects (guns) they all have instance variables like accuracy, dmg etc.

    I put them in my GameLayout and can access their instance variables.

    But i also have Shop Layout where i can upgrade these weapons (better accuracy, more dmg).

    How can i access these instance variables in this different Layout?

    I only have the Free Version so i can't just add a ton of global variables for the guns...

  • same way you did in the first layout. when creating a Event you will find your variables under System-global variables.

  • Well yes, i can access them....

    But they have no value. (but they should have one)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Really? hmm. well do like this then

    make an event, "Start of Layout" - action - "Set Value" and you can set the value again

    Let me know if it works or not

  • If you are doing Shop thing with many items then you could use array, to store all items in the shop (price, description, damage, accuracy...)

    and then use values from arrays with sprite instance variables

    for example in pseudo code

    Set sprite_gun.accuracy to Array.At(item_id, item_accuracy)

    Arrays are global by default so you can retrieve information from them on any layout in the game.

  • shinkan

    thanks that seems to work....

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