How do I Make an Event from One Layout affect the Other?

Get help using Construct 2

Post » Mon Sep 11, 2017 11:27 pm

Basically in Layout 1 when you click an object it's supposed to update a number in layout 2, but doesn't. I tried to put the number in the same layout and that worked, but I want the number in a separate layout.
B
9
S
1
Posts: 42
Reputation: 519

Post » Tue Sep 12, 2017 1:30 am

How do you store this number?
If it's a variable on your event sheet, just make it Global, it should be visible to both layouts.
You can also create an array or a dictionary and store your number there, or you can add an instance variable to some object accessible from both layouts.
The dictionary would probably be the best solution.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
70
Posts: 1,054
Reputation: 38,171

Post » Tue Sep 12, 2017 4:41 pm

dop2000 wrote:How do you store this number?
If it's a variable on your event sheet, just make it Global, it should be visible to both layouts.
You can also create an array or a dictionary and store your number there, or you can add an instance variable to some object accessible from both layouts.
The dictionary would probably be the best solution.


Capx Example by any chance?
B
9
S
1
Posts: 42
Reputation: 519

Post » Wed Sep 13, 2017 1:23 am

Here you go:
https://www.dropbox.com/s/f0952pplmsucm ... .capx?dl=0

I tried to make it simple as I understand you are new to this.

Of course many things can be optimized there because both layouts are very similar and share most of the code.
You can move repeating pieces of code to functions, or you can even make both layouts to use the same event sheet.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
70
Posts: 1,054
Reputation: 38,171

Post » Wed Sep 13, 2017 2:03 am

Message: CaesarSalad can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
dop2000 wrote:Here you go:
https://www.dropbox.com/s/f0952pplmsucm ... .capx?dl=0

I tried to make it simple as I understand you are new to this.

Of course many things can be optimized there because both layouts are very similar and share most of the code.
You can move repeating pieces of code to functions, or you can even make both layouts to use the same event sheet.


Thank you so much, I'll check it out :)

Edit: I'll update in a day or so if I can get this working in my game, thank you so much for taking your time to do that I didn't expect it to have so many events.
B
9
S
1
Posts: 42
Reputation: 519

Post » Wed Sep 13, 2017 2:13 am

CaesarSalad wrote:I didn't expect it to have so many events.

That's because there are 3 examples - using a variable, dictionary and array.
And, like I said, most events are identical in both layouts.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
70
Posts: 1,054
Reputation: 38,171


Return to How do I....?

Who is online

Users browsing this forum: Seruza and 10 guests