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

Get help using Construct 2

Post » Sat Jul 26, 2014 8:32 am

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...
B
6
S
1
Posts: 30
Reputation: 1,059

Post » Sat Jul 26, 2014 9:42 am

same way you did in the first layout. when creating a Event you will find your variables under System-global variables.
B
6
Posts: 37
Reputation: 324

Post » Tue Jul 29, 2014 7:30 pm

Well yes, i can access them....
But they have no value. (but they should have one)
B
6
S
1
Posts: 30
Reputation: 1,059

Post » Wed Jul 30, 2014 5:49 pm

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
B
6
Posts: 37
Reputation: 324

Post » Wed Jul 30, 2014 5:58 pm

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.
ImageImageImageImage
B
158
S
66
G
43
Posts: 2,603
Reputation: 35,868

Post » Thu Jul 31, 2014 10:33 am

@shinkan

thanks that seems to work....
B
6
S
1
Posts: 30
Reputation: 1,059


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests