How do I keep Instance Vars from resetting

Get help using Construct 2

Post » Wed Nov 05, 2014 6:06 am

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!
B
3
Posts: 2
Reputation: 179

Post » Wed Nov 05, 2014 6:27 am

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.
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Wed Nov 05, 2014 6:30 am

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
B
19
S
2
G
1
Posts: 24
Reputation: 1,475

Post » Wed Nov 05, 2014 6:37 am

Thank you loads, guys. This really helped me out, appreciate the replies!
B
3
Posts: 2
Reputation: 179


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, Bootfit, brunopalermo, Exabot [Bot], Huemerson, unicornspitfire, Yahoo [Bot] and 1 guest