How do I keep Instance Vars from resetting

  • Firstly, this is my first post here, so if I did anything wrong in posting, I apologize. Also, I looked around for solutions for this problem, and I either over looked it, or didn't find one, so hence why I am asking here.

    When I switch layouts, the Object Instance Variables reset. Is there any way to get around this? I know I can use global vars, but I wanted to know if there is a way to use Instance Vars from an Object throughout multiple layouts without them resetting.

    An example of a reason I want to use this:

    I want to keep track of the win/lose of a monster for a pokemon-like game. I want to store the values in the monsters Instance Variables when the monster wins or loses a match (Note, this is only for that single monster's win/lose, not over all win/lose).

    I also have made a stat screen displaying the stats for each of your monsters, the only thing is when i switch to the layout containing the stats, it doesn't display the value of the win/lose because the Instance Vars of the Object reset.

    Thanks in advance to anyone who takes the time to reply!

  • You can make spawned/created object as global. However, for me I would approach it using array all the way and load the data from array into the instance var everytime. This way I can safely destroy object if necessary.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • As DuckfaceNinja already stated, you can set your objects to be global in the object type properties panel, so they don't get destroyed at the end of a layout.

    Have fun

  • Thank you loads, guys. This really helped me out, appreciate the replies!

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